Question: Create a new variable and set it equal to the inputted value minus 1 Create a while loop that runs while the variable (that represents

  1. Create a new variable and set it equal to the inputted value minus 1
  2. Create a while loop that runs while the variable (that represents the index value that we want to print) is greater than or equal to the minimum array value.
  3. Within the while loop have two things happen.
    1. Have the innerHTML of some element within your page be replaced with the array value that corresponds to the index number that we want printed
      1. You specify the array value by the format arrayname[indexnumber]

function duty(){ var inputval = parseInt(document.getElementById("demo").value ); var displayVl = document.getElementById("displayVl"); var jobduty = ["1","2","3","4","5"]; var displayVal = ""; while(inputval >= 0 ) { inputval-- } displayVl.innerHTML = displayVal; }

I'm having trouble with a while loop using the instructions above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!