Javascript Array Question 22

Introduction

Array with Odds

Create an array with odd integers from 1-255.


function array_odds_255() {
  var arr = [];
  //
  return arr;
}
array_odds_255();


function array_odds_255() {
  var arr = [];
  for (var i = 1; i <= 255; i++) {
    if (i % 2 == 1) {
      arr.push(i);
    }
  }
  return arr;
}
array_odds_255();



PreviousNext

Related