Fizz buzz question - Node.js Number

Node.js examples for Number:Algorithm

Description

Fizz buzz question

Demo Code


Number.prototype.hasMult = function( n ) {
  return Number.isInteger( this / n )
}

function fun100() {
  out = []/*ww w  . j  a  v  a2  s.c o m*/
  for ( var i = 1; i <= 100; i++ ) {
    if ( i.hasMult(3) ) {
      out.push['Fizz']
    }
    else if ( i.hasMult(5) ) {
      out.push['Buzz']
    }
    else if ( i.hasMult(5) && i.hasMolt(3) ) {
      out.push["Fizzbuzz"]
    }
    else {
      out.push( i.toString() )
    }
  }
  return out
}

Related Tutorials