Created
June 1, 2022 03:01
-
-
Save almcarvalho/c6a95f47b04c6eb70cdc0b70a62bbb6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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