Question

I need the JavaScript and pseudocode for the following problem please: . Write a script that...

I need the JavaScript and pseudocode for the following problem please:

. Write a script that outputs HTML5 text that keeps displaying in the browser window the multiples of the integer 2- namely, 2, 4, 8, 16, 32, 64, etc. Your loop should not terminate (create an infinite loop). What happens when you run this script

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the pseudocode of the method

1. Initialize a counter to 1

2. run a while loop with condition that counter is greater than 0. This loop condition will always be true so loop will runinfinitely

3. print the value of counter*2 and a comma

4. update the counter as counter = counter * 2

Because the counter always remains greater then 0, it will keep on running infinitely.

Below is your HTML code:-

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns ="http://www.w3.org/1999/xhtml">

<head>
   <script type = "text/javascript">
       var powerOfTwo = 1;
      
       while ( powerOfTwo > 0 )
       {
           document.writeln( powerOfTwo*2 + ", " );
           powerOfTwo *= 2;
       }
   </script>
  
</head>

<body>

</body>

</html>

When we run the scipt, the page will not load and will become unresponsive because of infinite loop

Add a comment
Know the answer?
Add Answer to:
I need the JavaScript and pseudocode for the following problem please: . Write a script that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with the following question Write a script based on the program in Exercise...

    I need help with the following question Write a script based on the program in Exercise 11.13 that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text. Uppercase and lowercase letters should be counted together. Store the totals for each letter in an array, and print the values in tabular format in an HTML5 textarea after the totals have been determined. I need...

  • Problem 1 Write a BASH script to create a user account from the Linux system on...

    Problem 1 Write a BASH script to create a user account from the Linux system on which your script is run. The script should process two positional parameters. First positional parameter is supposed to be a string with a user name (e.g., user_name) Second positional parameter is supposed to be a string with a user password (e.g., user_password) In your script: Check if two positional parameters were passed to your script when it was invoked If NOT, print an appropriate...

  • JavaScript - I need help formulating executable code for the following problem. 7.15 The process of...

    JavaScript - I need help formulating executable code for the following problem. 7.15 The process of finding the largest value (i.e., the maximum of a group of values) is used frequently in computer applications. For example, a script that determines the winner of a sales contest would input the number of units sold by each sales person. The salesperson who sells the most units wins the contest. Write a pseudocode ode algorithm and then a script that inputs a series...

  • Please help me with the following requirements for JavaScript. Write a function to take a temperature value in Celsius a...

    Please help me with the following requirements for JavaScript. Write a function to take a temperature value in Celsius as an argument and return the equivalent temperature in Fahrenheit, basing it on the code from Hour 2. //Original Code <!DOCTYPE html> <html> <head>     <title>Fahrenheit From Celsius</title> </head> <body>     <script>         var cTemp = 100;  // temperature in Celsius         var hTemp = ((cTemp * 9) /5 ) + 32;         document.write("Temperature in Celsius: " + cTemp + " degrees<br/>");         document.write("Temperature in Fahrenheit: "...

  • i need the code that goes within the <script> opening and closing following the insturctions of...

    i need the code that goes within the <script> opening and closing following the insturctions of the insturctions of the pasted assignment screen shots please. <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 3 Hands-on Project 3-1 Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Hands-on Project 3-1</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 3-1 </h1> </header> <article> <h2>Lunch selections</h2> <form> <input type="checkbox" id="item1" value="8" /> <label for="item1">Fried chicken ($8.00)</label> <input type="checkbox"...

  • Please help me write a Pseudocode (please do NOT answer in JAVA or Python - I...

    Please help me write a Pseudocode (please do NOT answer in JAVA or Python - I will not be able to use those). Please ALSO create a flowchart using Flowgarithm program. Thank you so much, if answer is provided in Pseudocode and Flowchart, I will provide good feedback and thumbs up to the resonder. Thank you! Tic-Tac-Toe Game Write a program that allows two players to play a game of tic-tac-toe. Use a two- dimensional char array with three rows...

  • Please complete the following: Write a Python script to do the following: 1. Ask the use...

    Please complete the following: Write a Python script to do the following: 1. Ask the use to enter several sentences, one at a time in a loop). To end the sentence entry, the user enters a blank (empty) sentence. 2. Extract each word from each sentence and put it in a list. This will require at least one loop to go through each sentence in the list. It is up to you how you want to get the words in...

  • PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions...

    PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan. Create an m-file function called "mortgage_a.m" that will serve as...

  • I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions...

    I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement: srand((unsigned int)time (NULL)); which will give the random number generator a random starting point. Note: srand and rand require the TIME.H (or iomanip) cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation. 2....

  • given below are the project description and their Html and css files i need javascript according...

    given below are the project description and their Html and css files i need javascript according to the project and other files! WEB230 - JavaScript 1 Assignment 6b - Event Delegation Before starting, study the HTML and open it in a browser so that you understand the structure of the document. You will add functionality to perform several tasks in our shopping list app. Clicking the red "X" at the right of an item will delete that item. Clicking on...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT