Currently learning ES 6 & 7, i wrote a function to mix an array and i wanted to train by "translating" this function to es 6, it seems to not work and i don't find my mistake, can anyone help me ?
const arr = [1, 2, 3, 4, 5]
var mixer = array => {
for (let i = 0; i < array.length; i++) {
let randomized = Math.round(Math.random() * array.length)
[array[randomized], array[i]] = [array[i], array[randomized]]
}
return array
}
mixer(arr)
here's the error i receive from google chrome
Uncaught ReferenceError: randomized is not defined at mixer (prog.js:6) at prog.js:11
Thank you for your help :)