Question
Given the following code - Update the condition to incorporate the .toUpperCase method === 'RUBY' this way, it doesn't matter if the user enters the
Given the following code - Update the condition to incorporate the .toUpperCase method === 'RUBY' this way, it doesn't matter if the user enters the answer in lowercase,the condition is passed since the answer is converted to upper case letters; therfore matching the string
// obtain a response from the user let answer = prompt('What programming language is the name of a gem?');
//just like let is used to declare variables, the let keyword is user for // a conditional statement
if ( answer === 'Ruby' )
//inside the parenthesis is the condition just // a simple test whose answer is either true or false in this example // the given answer must match exactly
// inside the braces is the code that runs only if the statement is true { document.write("
You are right, good thinking !
") //indenting the code mades it easier to read }else { //this block of code will run only if the answer if NOT Ruby document.write("
Darn, your answer if not right!
") }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started