My current challenge involves a 2-dimensional Array where I am attempting to implement a "randomBool" function on each of the elements within it.
The "randomBool" function essentially generates a random boolean value:
const randomBool = () => Boolean(Math.round(Math.random()));
Here is the 2-dimensional Array that I am working with:
var test = [
["just","some","random","text"],
[1412,"test",1278391]
]
I have structured a nested for-loop as follows:
for (let el of test){
for(let i in el){
el[i] = randomBool();
}
}
I initially attempted this solution using map but encountered an issue:
test.forEach(el => el.map(el2 => randomBool()));
However, this approach was unsuccessful. Can anyone provide insights into why it didn't work?