← Back to challenges

Is the String Odd or Even?

JavaScriptMediumstringsconditionsvalidation

Instructions

Given a string, return true if its length is even or false if the length is odd.

Examples

oddOrEven("apples") ➞ true
// The word "apples" has 6 characters.
// 6 is an even number, so the program outputs true.

oddOrEven("pears") ➞ false
// "pears" has 5 letters, and 5 is odd.
// Therefore the program outputs false.

oddOrEven("cherry") ➞ true

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: ES6: Destructuring Arrays I