Day 5: For . . . Of
-
-
monzee 9 years ago 'use strict';
is needed at the start of the enclosing block, but we don't have control over that since the code we submit is pasted in the middle of the actual script being executed by the server. Need to wrap it in a function, declare strict then call the function. Which is too much work, so just usevar
.
EDIT: I'm wrong, you can just add
'use strict';
at the top. Maybe the submission is being enclosed in a function.-
[deleted] 9 years ago Try adding "use strict" at top of your second code.
"use strict" for(let str of my_array){ if(str === str.split('').reverse().join('')){ console.log(str); } }
You can learn more about "use strict" here
-
jenishrabadiya 9 years ago Thanks!
-
karuna24s 9 years ago When I click on the link mdn says not found. Do you recommend another resource?
-
matteo_chini 9 years ago Use this, there is a '.' at the end of the link ;) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
-
karuna24s 9 years ago Thank you :)
-
-
-
-
jenishrabadiya 9 years ago thanks! that helped me understand correctly. :)
-
-
Odiumediae 9 years ago -- edited -- I removed my comment, to avoid confusion among newbies.
-
jenishrabadiya 9 years ago I wrapped it inside the function but it did not work. we need to write "use strict" in order to make it work.
-
Odiumediae 9 years ago +1 I'm sorry, you're right, I even did that myself. I've mixed that up with something else. Thanks to DOSHI.
-
-
-
avi2604 8 years ago because if you will use let then you cant change value of varible its work like final keyword from java
-
Below code worked fine where I declared for loop variable with the keyword var.
but when I use let keyword it does not work
What is the reason?
Add Reply Preview cancel