Skip to content

Instantly share code, notes, and snippets.

@codingedgar
Last active August 28, 2018 15:00
Show Gist options
  • Save codingedgar/583368bce1614debf20775c38a231fc1 to your computer and use it in GitHub Desktop.
Save codingedgar/583368bce1614debf20775c38a231fc1 to your computer and use it in GitHub Desktop.
until transducer: for_fouble
function double_every_element(numbers: number[]) {
let result: number[] = [];
for (let i = 0; i < numbers.length; i++) {
result.push(2 * numbers[i])
}
return result;
}
test('double numbers in list using for statement', () => {
expect(double_every_element([1, 2, 3])).toEqual([2, 4, 6])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment