Skip to content

Instantly share code, notes, and snippets.

@73nko
Last active December 26, 2021 09:48
Show Gist options
  • Save 73nko/ca1e0f345e2f51cca092dc0f5e037e62 to your computer and use it in GitHub Desktop.
Save 73nko/ca1e0f345e2f51cca092dc0f5e037e62 to your computer and use it in GitHub Desktop.
const array = [1, 2, 3, 4, 5];
function copyAndMultiplyBy2(array) {
var newArray = [];
for (var i = 0; i < array.length; i++) {
newArray.push(array[i] * 2);
}
return newArray;
}
function copyAndDivideBy2(array) {
var newArray = [];
for (var i = 0; i < array.length; i++) {
newArray.push(array[i] / 2);
}
return newArray;
}
const arrayMultiplied = copyAndMultiplyBy2(array);
const arrayDivided = copyAndDivideBy2(array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment