I'm trying to get an array I've called input and loop over it.
If any values are odd numbers then they get multiplied by 2.
If any are even they get divided by 2 and are then pushed to an output array which I can then return.
So far I have this, (using cmd node):
function modify(input) {
var output = [];
for (i=0; i=input.length; i++) {
if (input % 2 == 1) {
input*2;
output.push[input];
}
if (input % 2 == 0) {
input/2;
output.push[input];
}
}
return output;
}
module.exports.modify = modify;
Aucun commentaire:
Enregistrer un commentaire