Created
March 20, 2020 08:59
-
-
Save edoves/ffe9bd35a1e881e9f608a04f5872aa40 to your computer and use it in GitHub Desktop.
divisibleby3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello; Hello World; World | |
Write a function that takes an integer and: | |
If the number is a multiple of 3, return "Hello". | |
If the number is a multiple of 5, return "World". | |
If the number is a multiple of both 3 and 5, return "Hello World". | |
helloWorld(3) ➞ "Hello" | |
helloWorld(5) ➞ "World" | |
helloWorld(15) ➞ "Hello World" | |
// Answer | |
function helloWorld(num) { | |
if (num % 15 == 0) return "Hello World"; | |
else if (num % 3 == 0) return "Hello"; | |
else if (num % 5 == 0) return 'World'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment