Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save almcarvalho/c6a95f47b04c6eb70cdc0b70a62bbb6b to your computer and use it in GitHub Desktop.
Save almcarvalho/c6a95f47b04c6eb70cdc0b70a62bbb6b to your computer and use it in GitHub Desktop.
//DESAFIO
//https://www.codewars.com/kata/55fd2d567d94ac3bc9000064/javascript
function rowSumOddNumbers(n) {
let contador = 1;
let numbers = 1;
let soma = 0;
for (let index = 0; index < n; index++) {
soma = 0;
for (let index = 0; index < contador; index++) {
//console.log(numbers);
soma += numbers;
numbers = numbers + 2;
}
contador++;
}
return soma;
}
console.log(rowSumOddNumbers(3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment