+ 1

JavaScript - From letters to digits

Output is "012345". How is it letters are "transformed" in digits? let result = ""; for(let i in "abcdef"){ result += i; } document.write(result);

14th Oct 2019, 11:50 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
4 Answers
+ 3
its not converting, but it take the index from the array
14th Oct 2019, 12:05 PM
Taste
Taste - avatar
+ 2
no, it take the properties. you can use for of to take the value
14th Oct 2019, 12:15 PM
Taste
Taste - avatar
+ 1
Shouldn't it take values?
14th Oct 2019, 12:12 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
+ 1
for...of vs for...in Loops in JavaScript https://alligator.io/js/for-of-for-in-loops/
14th Oct 2019, 12:55 PM
ODLNT
ODLNT - avatar