Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const oddOrEven = (int) => {
- if (typeof int == "string" && int) {
- if (parseInt(int) % 2) return "Odd"
- else return "Even"
- } else if (typeof int == "number") {
- if (int % 2) return "Odd"
- else return "Even"
- } else return undefined
- }
- // example
- // code | expected output
- oddOrEven(0) // Even
- oddOrEven(10) // Even
- oddOrEven("0") // Even
- oddOrEven("10")// Even
- //
- oddOrEven(1) // Odd
- oddOrEven(11) // Odd
- oddOrEven("1") // Odd
- oddOrEven("11")// Odd
Add Comment
Please, Sign In to add comment