Site icon Tutor Bin

The Code Uses Nested Loops and The the Missing Code Question

The Code Uses Nested Loops and The the Missing Code Question

Description

Question 1: 

The following code uses nested loops and “document.write” to output the following triangle: 

#

##

###

####

#####

######

#######

What is the missing code (indicated by the underscore __ ) in the program below that would make this program function as described?

for(var x=7;x__;x__){for(var y=i;y__;y__){document.write("#");}

document.write("<br>");}

Question 2 

  1. Prompt the user for a name that is at least 5 characters long.
  2. Call a function that can accept the name that the user entered.
  3. In the function, change the case of the letters so that the first letter is lower case and the next letter is Uppercase and so on (i.e. eXaMpLe) and return the new value to the function call.
  4. Output to the console “Hi <username>, how do you like when I write you name like this: <new user name>”? (replace <username> and <new user name> with the proper values).

Question 3 

Here are the rules:

  1. The dealer is assigned a random number between 2 and 21
  2. The player is given a random number between 1 and 11.
  3. The user can request another number, it is then added to their original value.
  4. If the value is under 21, the user can ask for another number (y) OR stay (n).
  5. If the player’s amount is over 21, they lose.
  6. Once they stay, the players’ amount and the dealer’s amount are compared.
  7. Whomever has the higher amount wins, if they are equal, it’s a tie.

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Exit mobile version