scrimba
Note at 0:14
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:14
AboutCommentsNotes
Note at 0:14
Expand for more info
index.js
run
preview
console
/* Whispering function 
Write a function `whisper` that takes in a sentence
and returns a new sentence in all lowercase letters with
"shh..." at the beginning.

The function should also remove an exclamation point
at the end of the sentence, if there is one.

Example
input: "The KITTENS are SLEEPING!"
output: "shh... the kittens are sleeping"

Hint: endsWith and slice
*/

function whisper(sentence) {

if(sentence.endsWith('!')) {
return `shh... ${sentence.slice(0,-1).toLowerCase()}`;
} else {
return `shh... ${sentence.toLowerCase()}`;
}
}

console.log(whisper("PLEASE STOP SHOUTING."));
console.log(whisper("MA'AM, this is a Wendy's!"));
Console
"shh... please stop shouting."
,
"shh... ma'am, this is a wendy's"
,
/index.html
LIVE