javascript - I'm trying to write a function that Randomizes a number (range 0..100), then prints all the odd numbers from 40 to that one -


i'm new javascript , i'm struggling basics. can't code work.

i'm trying create function (the following taken form exercise i'm doing) randomizes number (range 0..100), prints odd numbers 40 one. if number smaller 40, print numbers down randomized 1 (i.e. if result 37, should print: 40, 39, 38, 37).

your input appreciated.

var sol3 = function() {     var n = math.floor(math.random()*100);      if (n > 40) {         for( var = 41; <= 100; i++2);         console.log(i);     }     else if (n < 40) {         (var = 39; <= 40; i--2);         console.log(i);     }      return i; };  so13(); 

problems code -

  1. i++2 incorrect
  2. ; after for incorrect
  3. i--2 incorrect
  4. you calling sol13() number 1 there not letter l
  5. return i works!

demo here

var sol3 = function () {     var n = math.floor(math.random() * 100);      console.log("n = " + n);      if (n > 40) {          (var = 41; <= n; += 2)             console.log(i);      } else if (n < 40) {          (var = 40; >= n; i--)             console.log(i);     }      return i;  };  sol3(); 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -