javascript - Making a simple timetable work using an array and nested loops? -
i have problem want make timestable output console.log, having problems array beginner. here code, been staring while @ this. sincerely.
<script> // simple array store , output times’ tables var timestable = new array(12); var multiplier =6; timestable[0] = 0 * multiplier; timestable[1] = 1 * multiplier; timestable[2] = 2 * multiplier; timestable[3] = 3 * multiplier; timestable[4] = 4 * multiplier; timestable[5] = 5 * multiplier; timestable[5] = 5 * multiplier; (multiplier=0; multiplier<13; multiplier++){ console.log("0 x " + multiplier + " = " + timestable[12]) (timestable=0; timestable<12; timestable++){ }} </script>
// create array var = []; var multi = 6; // fill array values (var = 0; < 12; i++) { a.push(i); } // multiply every array-element 6 , create new array var b = a.map(function (j) { return j * multi; }) // log (i = 0; < b.length; += 1) { console.log(i + ' x ' + multi + ' = ' + b[i]); // or: // console.log(a[i] + ' x ' + multi + ' = ' + b[i]); }
Comments
Post a Comment