Skip to content

Instantly share code, notes, and snippets.

@Arieg419 Arieg419/imperative.js
Last active Nov 27, 2017

Embed
What would you like to do?
Examples of imperative code
// triple the value of every element in a given array
const triple = (arr) => {
let results = []
for (let i = 0; i < arr.length; i++){
results.push(arr[i] * 3)
}
return results
}
// sum all the elements in a given array
const sum = (arr) => {
let result = 0
for (let i = 0; i < arr.length; i++){
result += arr[i]
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.