You can also use Array.includes() : function checkMonth ( month ) { const compareMonths = [ 'January' , 'March' , 'May' , 'July' , 'August' , 'October' , 'December' ]; // we can use ternary instead of if ...else return compareMonths.includes(month) ? ` ${month} has 31 days` : ` ${month} doesn't have 31 days` ; } console .log(checkMonth ( 'July' )); // "July has 31 days" console. log (checkMonth ('February')) // "February doesn't have 31 days"