Javascript Object Question 3

Introduction

What is the output of the following code?


function monthName(monthNum) {
  let monthArray = {'0':'January', 
                    '1':'February', 
                    '2':'March', 
                    '3':'April', 
                    '4':'May', 
                    '5':'June', 
                    '6':'July', 
                    '7':'August', 
                    '8':'September', 
                    '9':'October', 
                    '10':'November', 
                    '11':'December'};
  if (!isNaN(monthNum) && (monthNum >= 0 && monthNum <= 11)) {
    return monthArray[monthNum];
  } else {/*from   w w w . jav a  2  s  .c om*/
    return Number.NaN;
  }
}

console.log(monthName(1));  
console.log(monthName(7));
console.log(monthName(33) );  


February
August
NaN



PreviousNext

Related