Skip to content

Instantly share code, notes, and snippets.

@thedom85
Created June 14, 2022 08:14
Show Gist options
  • Save thedom85/925af7428bf28fbd561982ed0715b138 to your computer and use it in GitHub Desktop.
Save thedom85/925af7428bf28fbd561982ed0715b138 to your computer and use it in GitHub Desktop.
// https://www.codewars.com/kata/57a083a57cb1f31db7000028/train/javascript
function powersOfTwo(n){
var outcome =[];
for (let i = 0; i <= n; i++) {
outcome.push(Math.pow(2, i));
}
return outcome
}
console.log(powersOfTwo(0), [1])
console.log(powersOfTwo(1), [1, 2])
console.log(powersOfTwo(4), [1, 2, 4, 8, 16])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment