Given a variable message
a string value, as an argument.
Create a program comprehensiveExercise
which takes message
as a parameter
and does the following operations:
- Log to the console the length of the variable message like
The length of [message] is [length]
.
- Log to the console the character at index 0 of the variable message like
The first character of [message] is [character]
.
- Log to the console the last character of message using length like
The last character of [message] is [character]
.
- Log to the console the index of word "tell" in message.
- Log to the console whether the word "the" exist in message or not, output should be a boolean (true or false).
- Log to the console whether the word "The" exist in message or not, output should be a boolean (true or false).
- Check and log to the console whether the word from index 12 to 15 is "you", output should be a boolean (true or false).
- Check and log to the console whether the last character in message is "heard.", output should be a boolean (true or false).
- Log message as
lowercase
to the console.
- Log message as
UPPERCASE
to the console.
- Replace the word "greatest" to "worst" using newMessage variable, and re-assign the output to the variable
newMessage
and log it to the console.
- Log all the characters from the message variable separately to the console as such:
'character-1'
'character-2'
'character-3'
- Split all the words in message and store it in a variable
messageArray
and log all the words of messageArray
to the console.
- Log the message for first 6 characters of quote like this.
The character at index 0 is [character]
The character at index 1 is [character]