This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
Creating an array of negative and positive integers, only displaying odd values
Post Flair (click to view more posts with a particular flair)
Post Body
I am trying to make a function that will display a set of numbers that are odd and include both negative and positive integers in a descending order.
For example, it should be logging
[11, 9, 7, ..., -7, -9, -11]
function descendingOdd(min, max) {
let array = [];
if (min % 2 !== 0 && max % 2 !== 0) {
for (let i = min; i <= max; i ) {
array.push(i);
}
let descendingArray = array.sort(function (a, b) {
return b - a;
});
document.write("<br>" `Descending Negative Numbers : ${descendingArray}`);
}
}
console.log(descendingOdd(-12, 12));
My console log is giving me undefined and I'm not sure why.
Edit: Nvm, I think I have an idea. Will update soon
Author
Account Strength
100%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
9,114
Link Karma
553
Comment Karma
8,165
Profile updated: 2 days ago
Posts updated: 1 month ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...