You may do these challenges all together in one file, or in separate files, according to your preference. You will turn them in all together.
- Declare a function called
capitalizethat takes one argument,word - Within the function, capitalize the word
- Return the capitalized word
- When you run
console.log(capitalize("hello"))you should getHELLO
- Declare a function called
percentCalcthat takes two arguments,amountandpercentage - Return the given percentage of the amount
- When you run
console.log(percentCalc(200, 20))you should get40
- Declare a function called
divisiblethat takes two argments,dividendanddivisor - Determine whether the dividend is divisible by the divisor (meaning the division will result in a whole number with remainder)
- Tip: Use the modulo operator
- Return true or false
- When you run
console.log(divisble(6, 3))you should gettrue - When you run
console.log(divisble(15, 4))you should getfalse
- Declare a function called
greetingthat takes in two arguments,firstNameandstatus - Inside the function, write a conditional that determined whether
statusis the string"friend"or the string"enemy" - If the person is a friend, return the string that welcomes them by their name
- If the person is an enemy, return a string that tells them to go away
- When you run
console.log(greeting("Superman", "friend"))you should get something likeHello Superman! - When you run
console.log(greeting("Lex Luthor", "enemy"))you should get something likeGo away Lex Luthor!
- What do you think this function should do if the second argument doesn't match
"friend"or"enemy"? Think of something fun and implement it!