1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gogolik [260]
3 years ago
8

What is the value of the totalsString variable after the following code is executed? var totals = [141.95, 212.95, 411, 10.95];

totals[2] = 312.95; var totalsString = ""; for (var i = 0; i < totals.length; i++) { totalsString += totals[i] + "|"; }
Computers and Technology
1 answer:
Alex Ar [27]3 years ago
7 0
<h2>Answer:</h2>

141.95|212.95|312.95|10.95|

<h2>Explanation:</h2>

<em>Reformatting the code snippet and giving it line numbers;</em>

1.       var totals = [141.95, 212.95, 411, 10.95];

2.      totals[2] = 312.95;

3.      var totalsString = "";

4.      for (var i = 0; i < totals.length; i++) {

5.          totalsString += totals[i] + "|";

6.      }

Line 1 creates an array called totals with four elements.

     First element = totals[0] =141.95

     Second element = totals[1] = 212.95

     Third element = totals[2] = 411

     Fourth element = totals[3] = 10.95

Line 2 replaces the value of the third element <em>totals[2]</em> = 411 with 312.95.

     Therefore the array <em>totals = </em>[141.95, 212.95, 312.95, 10.95]

Line 3 creates an empty string called totalsString

Lines 4 - 6 create a for loop that cycles from i=0 to i<totals.length

       totals.length = 4 (which is the number of items in the array totals)

       This means that the loop cycles from i=0 to i<4

       During cycle 1 when i = 0, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[0] + "|"   //substitute the values

            totalsString = "" + 141.95 + "|"

            totalsString = 141.95|

       During cycle 2 when i = 1, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[1] + "|"   //substitute the values

            totalsString = "141.95|" + 212.95 + "|"

            totalsString = 141.95|212.95|

       During cycle 3 when i = 2, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[2] + "|"   //substitute the values

            totalsString = "141.95|212.95|" + 312.95 + "|"

            totalsString = 141.95|212.95|312.95|

       During cycle 4 when i = 3, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[3] + "|"   //substitute the values

            totalsString = "141.95|212.95|312.95|" + 10.95 + "|"

            totalsString = 141.95|212.95|312.95|10.95|

At the end of the execution, totalsString = 141.95|212.95|312.95|10.95|

You might be interested in
I am writing a Python code to ask a user to enter students' information including name,
White raven [17]

Answer:

student_file = {}

endf_input = '1'

for x in iter(list, 1):

   name = input("Enter a student name: ")

   st_id = int(input("Enter a student id number: "))

   student_file[name] = st_id

   endf_input = input("Add more student to file (type 1 for yes and 0 to end): ")

   if endf_input == '0':

       break

print("Search for Student")

search = int(input("Enter student id: "))

if search == 0:

   print("Sorry, no student with id of zero.")

   quit()

for key, value in student_file.items():

   if value == search:

       print(f"Student name: {key}")

Explanation:

The program source code uses a for loop to continuously add data to the student file dictionary structure but breaks from the loop when a zero is received as input. The program enters search mode and returns the name of the student with the searched id number.

7 0
3 years ago
When using bits to represent fractions of a number, can you create all possible fractions? Why or why not?
seropon [69]

Explanation:

Using this technique a number is represented in bits by three parts: sign, exponent, and fraction. This is similar to scientific notation used to represent large or small numbers (e.g. ). The sign is negative, the exponent is 8 and the fraction is 0.35.

8 0
3 years ago
With simple segmentation, a process is divided into a number of segments that need not be of equal size. When a process is broug
hoa [83]

Answer:

The missing word is <em>backing store.</em>

Explanation:

A backing store is a device for secondary storage of data that typically has greater capacity than the primary store but is slower to access.

A process must be loaded into memory in order to execute.

If there is not enough memory available to keep all running processes in memory at the same time, then some processes who are not currently using the CPU may have their memory swapped out to a fast local disk called the backing store.

The backing store may be the Hard Disk Drive or a Universal Serial Bus Drive.  The backing store can sometimes be referred to as <em>virtual memory.</em>

This memory that appears to exist as main storage although most of it is supported by data held in secondary storage, transfer between the two being made automatically as required.

Cheers!

4 0
3 years ago
Why is information so important in our lives
GREYUIT [131]
Information is very important because it helps us as a society make decisions. Decisions are impossible without information, and we are constantly seeking information in everything we do. Information is important in decreasing our sense of doubt and uncertainty as well.
5 0
3 years ago
Read 2 more answers
Have you searched Buzz Ch.at on playstore​
deff fn [24]

Answer:

Reorder terms.

y=52x−1

Cancel the common factor of 22.Factor 22 out of −2-2.

y−4=5x2+52⋅(2(−1))y-4=5x2+52⋅(2(-1))

Cancel the common factor.

y−4=5x2+52⋅(2⋅−1)y-4=5x2+52⋅(2⋅-1)

Rewrite the expression.

y−4=5x2+5⋅−1y-4=5x2+5⋅-1

Multiply 55 by −1-1.

y−4=5x2−5

3 0
3 years ago
Other questions:
  • Where can I easily find an easy app or program to use for making/editing videos?
    13·1 answer
  • What refers to the protocolâ s ability to ensure that data hasnâ t been modified in any way?
    15·1 answer
  • What are the importance of switches in our electron device
    15·1 answer
  • this device can be used to type documents,send email,browse the internet,handle spreadsheets,do presentations,play games,and mor
    14·1 answer
  • A green screen should be lit with which two lights?
    6·2 answers
  • Provide an example of making multiple paragraphs tags using html and at least 3 sentences.
    13·1 answer
  • The question of ________ arises when considering the way in which online marketers gather consumers’ information over the Intern
    6·1 answer
  • --------------------------------------------------------------------------------------------------------------------------------
    8·1 answer
  • Pleasee telllllllllllllllllll​
    15·1 answer
  • Professional communication must be objective,
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!