Question
Exercise 13A. Copy ct_Ex12.html and ct_Ex12.js to new files named ct_Ex13A.html and ct_Ex13A.js. In this exercise, you translate your flowchart of Ex 13A of Part
Exercise 13A. Copy ct_Ex12.html and ct_Ex12.js to new files named ct_Ex13A.html and ct_Ex13A.js. In this exercise, you translate your flowchart of Ex 13A of Part 1 to its equivalent JavaScript code.
Several changes that you need to make here are minor changes like what you did in previous exercises in html and js files. So, we do not re-state them here.
This exercise can be done with for loop, as iterations are deterministic. For instance, if input is 5, we need to iterate exactly 5 times to output those 5 rows; also, in each row i, we should put i pairs of []. So, we need to nest one loop inside another. Note: in this exercise you would need to change text alignment to left. You can do this just in your js code by modifying the style property of outputObj just before you enter the loop.
Once you are done, run the program, you should see the following result. Test your program with more inputs. Debug your code if the program does not give the expected results.
example :
if user input = 5
[]
[][]
[][][]
[][][][]
[][][][][]
----------
Exercise 13B. Copy ct_Ex13A.html and ct_Ex13A.js to new files named ct_Ex13B.html and ct_Ex13B.js. In this exercise, you translate your flowchart of Ex 13B of Part 1 to its equivalent JavaScript code, which
produces the inverted triangles. Sample output for inputs 5 and 8 are shown below.
example :
[][][][][]
[][][][]
[][][]
[][]
[]
i am providing the html and jss down below----
triangle with nested loops
------
// For: 23w EECS1012N, York University, Lassonde School of Engineering (LAS)
// in Ex7 to Ex13, change the name of the following function properly
function triangle() {
var outputObj = document.getElementById("output");
// this statement receives some data and parses it to integer
var a = parseInt(prompt("Please enter a number: ", ""));
var i,j;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started