I don't understand what is the problem here, when i put
array.lengthinside for loop it's giving wrong length.
let x = 'w3resource'
let y = x.split('');
let output = [];
// let len = y.length;
for(let i = 0; i < y.length; i++){
let z = y.pop();
output.push(z);
}
let alfa = output.join('');
console.log(alfa);
Now when i put it outside it's working correctly.
let x = 'w3resource'
let y = x.split('');
let output = [];
let len = y.length;
for(let i = 0; i < len; i++){
let z = y.pop();
output.push(z);
}
let alfa = output.join('');
console.log(alfa);
Please explain what's going on here?