Created
June 28, 2020 18:33
-
-
Save Alamin02/4098cc61dc9d501e76d7622c1af05659 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
function generateEvenNumberSequence(start, end) { | |
const sequence = []; | |
const firstValue = start % 2 === 0 ? start: start + 1; | |
for (i = firstValue; i <= end; i = i + 2) { | |
sequence.push(i); | |
} | |
return sequence; | |
} | |
console.log(generateEvenNumberSequence(1, 10)); | |
// Output: [1, 3, 5, 7, 9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment