In: Computer Science
2.Find an error in the following program
var tvShow = "The Office";
if (tvShow =null) {
console.log("You did not enter a TV show.");
else {
console.log(tvShow+ “ “);
}
3.Write a statement that assigns finalResult with the division of number1 by number2. Ex: If number1 is 6 and number2 is 2, finalResult is 3.
Var number1=6;
Var number2=2;
__________________________________________ (write an arithmetic calculation which gives the result 0)
Var finalResult=0;
4.What is the final value of numItems?
bonus = 0;
numItems = 1;
if (bonus > 10) {
numItems = numItems + 3;
}
Solution:
5.Display elements at indices 2 and 3 in the array userNumbers separated by a space.
Var userNumbers=[1,6,41,8,24,4];
/* Your Solution Goes here */
6. Matching basic document tag order
7. The HTML below has an error. What deprecated tag is causing the error?
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Learning HTML</title>
<body>
<center>This page uses deprecated HTML.</center>
</body>
</html>
8.What is the difference between line breaks and Whitespace in html?
9.What is output to the console?
var names = [];
names[0] = "Sue";
names[1] = "Bob";
names[2] = "Jeff";
console.log(names[0] + names[1]);
10.Write the missing table tags in the following program.
<table>
(a)
<th>Head 1 (b)
<th>Head 2</th>
(c) Head 3</th>
</tr>
<tr>
(d) Item 1</td>
<td>Item 2 (e)
<td>Item 3</td>
(f)
</table>
2)ans..
CODE:
var tvShow = "The Office";
if (tvShow ==null) { //here it assgin null to tcvShow
console.log("You did not enter a TV show.");
}
else {
console.log(tvShow+ "");
}
OUTPUT:
3)ans\
CODE:
var number1=6;
var number2=2;
var finalResult=number1/number2;
console.log(finalResult)
finalResult=number1%number2; //for result=0
console.log(finalResult)
OUTPUT":
4)
5)ans
CODE:
var userNumbers=[1,6,41,8,24,4];
console.log(userNumbers[2]) //display element as index 2
console.log(userNumbers[3]) //display element as index 3
6)
we need to give proper closing and ending tags like
<head></head>
<body></body>
<title></title>
<br />
7)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Learning HTML</title>
</head>
<body>
<center>This page uses deprecated
HTML.</center> <!-- this is deprecated -->
</body>
</html>
8)
line break is used to break the line and white space is used to give space between words as we required by manually if we type space it treats all the spaces as single space.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p>first line
second para
</p><br/>
<p>third npara</p>
<table>
<tr>
<th>Head 1 </th>
<th>Head 2</th>
<th> Head 3</th>
</tr>
<tr>
<td>Item 1</td>
<td>Item 2 </td>
<td>Item 3</td>
</tr>
</table>
</body>
</html>
9)
var names = [];
names[0] = "Sue";
names[1] = "Bob";
names[2] = "Jeff";
console.log(names[0] + names[1]); //print sue and bob
If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP....