I have the code
let arr = [1, 2, 3]; while (arr.length) { console.log(arr[arr.length - 1]); arr.pop(); } the output for this code is
3 2 1 1 but I expected
3 2 1 when I switch the code to
let arr = [1, 2, 3]; while (arr.length) { console.log(arr[arr.length - 1]); arr.pop(); } console.log(); I get
3 2 1 Why does it behave this way? Why am I getting a duplicate in the first code example? How can I prevent this? Thanks

← 1is not a log output.