This assignment uses arrays and loops to draw a chart based on user input. One function, getNumbers(), creates an array that stores the values to the chart. After collecting these values from the user, getNumbers() then loops through the array, calling drawSquares() to draw each line of the chart.

<html><head><title>Chapter 8 Assignment</title> <script type = "text/javascript"> <!-- hide me from older browsers // function getNumbers() gets a number of bars to draw // and the length of those bars. It calls the drawSquares() // function to actually draw the bars to the web page. // function getNumbers() { // create a new array // var the_values = new Array(); // find out how many bars the person wants // var how_many = prompt("How many ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.