ds-algo-study
Version:
Just experimenting with publishing a package
23 lines (16 loc) • 603 B
JavaScript
/******************************************************************************
Write a function oddRange(end) that takes in a number and returns an array
containing all positive odd numbers up to `end`.
Examples:
oddRange(13); // => [ 1, 3, 5, 7, 9, 11, 13 ]
oddRange(6); // => [ 1, 3, 5 ]
*******************************************************************************/
function oddRange(end) {
let arr = [];
for (let i = 1; i <= end; i += 2) {
arr.push(i);
}
return arr;
}
/**************DO NOT MODIFY ANYTHING UNDER THIS LINE*************************/
module.exports = oddRange;