+ 2
[ Solved ] Why this code is not working?
I learned that JavaScript counts positions from 0. But the following code is not working. Why? <script> var str = "Apple, Banana, Kiwi"; var res = str.substr(-0); document.getElementById("demo").innerHTML = res; </script>
2 ответов
+ 1
Not enough info..
Add full code..
It assigns full string...
0 or -0 is same
+ 2
If the length is 0 or negative value then it returns an empty string.
https://code.sololearn.com/WrvCsd9WY3Ss/#html