Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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----

EECS1012: Lab 5 - computational thinking

triangle with nested loops

(c) Author: jahid

------

// 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;

for (i=1;i

for(j=1;j<=i;j++){

}

}

/* this statement add some message to our output Object used for Ex8

you would need to change the message to be appropriate in Ex9 to E13 */

outputObj.innerHTML = "number: " + a + " " +;

outputObj.innerHTML += " " + "program ended";

document.getElementsByTagName("button")[0].setAttribute("disabled","true");

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

What is the perception that members have of the team?

Answered: 1 week ago

Question

define fiscal/financial viability

Answered: 1 week ago