Skip to content

Instantly share code, notes, and snippets.

@Alamin02
Created June 28, 2020 18:33
Show Gist options
  • Save Alamin02/4098cc61dc9d501e76d7622c1af05659 to your computer and use it in GitHub Desktop.
Save Alamin02/4098cc61dc9d501e76d7622c1af05659 to your computer and use it in GitHub Desktop.
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