Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created April 3, 2020 02:24
Show Gist options
  • Save sandrabosk/9f4f0e615e5c763f2a36970fc8d3f398 to your computer and use it in GitHub Desktop.
Save sandrabosk/9f4f0e615e5c763f2a36970fc8d3f398 to your computer and use it in GitHub Desktop.

Create a function named isNameOddOrEven that returns whether a student's name has an odd or even number of letters. Expected return should be in the following format - string: ' has an even/odd number of letters'. This function should accept one parameter, any string that represent the name you want to check.

function isNameOddOrEven(theName){
  // if (!theName) <===> if(theName.length === 0)
  if (!theName) return `Please enter the valid name!`
  if( theName.length % 2 === 0) return `${theName} has even number of letters`
  else return `${theName} has odd number of letters`
}
isNameOddOrEven('anamaria');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment