I know that the normal behavior of a for loop is similar to this:
for(let i = 0; i<5; i++){
console.log(i);
}
which gives me this result:
0
1
2
3
4
However the following code gives me a 5 as a result and I do not know why it doesn't give me a result similar to the example above.It doesn't behave as a for loop because it doesn't have into account the initializer. Thanks a lot for your help.
function charCount(str){
for(var i=2;i<=str.length;i++){
result = [i]
}
return result;
}
charCount('hello')