Skip to content

Instantly share code, notes, and snippets.

@giovannamoeller
Last active September 20, 2022 19:49
Show Gist options
  • Select an option

  • Save giovannamoeller/3c3922b81831144f89de01c25fb36f43 to your computer and use it in GitHub Desktop.

Select an option

Save giovannamoeller/3c3922b81831144f89de01c25fb36f43 to your computer and use it in GitHub Desktop.
const array = [1, 2, 3, 4];
function getDoubledArray(array) {
const arrayDoubled = [];
for (let i = 0; i < array.length; i++) {
const doubleValue = getDoubledValue(array[i])
arrayDoubled.push(doubleValue);
}
return arrayDoubled
}
function getDoubledValue(value) {
return value * 2;
}
const arrayDoubled = getDoubledArray(array);
console.log(arrayDoubled); // [2, 4, 6, 8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment