var array = [3, 4, 6, 5, 9, 10, 21];
var divThree = [];
var loveTheThrees = function (array) {
for (i = 0; i = array.length; i++) {
if (array[i] % 3 === 0) {
amount.push(divThree[i]);
}
}
}
I am just learning Javascript and having a bit of trouble with this function. I can feel im close but cant figure out what im doing wrong.
Just use filter()
divThree = array.filter(x => x%3 === 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With