The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I got two computer web code questions, these two questions involves javascript and dom.
1. Consider the following code fragments for index1.html
<html>
<head>
<title>Question 1</title>
<script src="/question1.js" type="text/javascript"></script>
<head>
<body>
<div class="funky"></div>
</body>
<html>
and for question1.js
var ROWS = 5;
var COLS = 4;
function go() {
var out = document.getElementsByClassName("funky");
var row = null;
for (var i=0; i < ROWS + COLS; i += 1) {
row = document.createElement("div");
var col = document.createElement("span");
col.innerHTML = " " + i^2 + " " + i^3;
if (i % 4 == 4) {
col.style.color = "puple";
}
row.appendChild(col);
out.appendChild(row);
}
}
window.onload = go
Cut and paste the above code into your virtual box. There are a number of errors in the files you
have been provided(question1.html, question1.js). Your task is to debug and correct these
errors so that the html page produces the desired ouput. You should not try to rewrite all the
code. The goal is to make as few changes as possible.
The html file should not be changed.
The javascript file should
1) call the function go when the page loads
2) programatically add 5 lines in the form of div elements inside the div with class "funky"
3) each added div should contain 6 span elements
4) each sucessive span element should should contain the text " N M" where N is the
number of span elements already added to the power 2 and M is the number of span elements
already added to the power 3.
5) even number span elements should be purple.
Â
Â
Â
Â
2. Consider the following code fragments for index2.html
<html>
<head>
<title>Question 2</title>
<script src="/question2.js" type="text/javascript"></script>
</head>
<body>
<div class="funky"></div>
</body>
</html>
and for question2.js
var RWS = 5;
var COLS = 5;
function golow() {
var out = document.getElementsByClassName("funky");
var table = document.createElement("table");
table.border = 1;
for (var i; i < ROWS; i += 1) {
var row = document.createElement("row");
for (var j; j < COLS; j += 2) {
var col = document.createElement("col");
col.innerHTML = String(i) + String(j);
if (j / 2 == 0) {
col.style.fontFamily="sans serif";
}
if (j / 3 == 21) {
col.style.color = "aquamrine";
}
}
table.appendChild(row);
}
out.appendChild(table);
}
window.onload = go
Cut and paste the above code into your virtual box. There are a number of errors in the files you have been
provided(question2.html, question2.js). Your task is to debug and correct these errors so that the html page produces the
desired ouput. You should not try to rewrite all the code. The goal is to make as few changes as possible.
The html file should not be changed.
The javascript file should
1) call the function go when the page loads.
2) the function go programatically adds a table inside the div with class "funky".
3) the table should have 15 rows and 15 columns.
4) the cells of the table should contain the text "A __
a" where A is a capital letter.
of the alphabet indexed by the row number and a is a lower case letter of the alphabet indexed
by the column number.
5) every odd should use bold text.
6) every even column should use sansserif
font.
7) every column number divisible by 3 should use the text colour aquamarine.
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly