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
- 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 the index value that we want to print) is greater than or equal to the minimum array value.
- Within the while loop have two things happen.
- 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
- You specify the array value by the format arrayname[indexnumber]
- 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
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
Get step-by-step solutions from verified subject matter experts
