Question

In: Computer Science

2.Find an error in the following program var tvShow = "The Office"; if (tvShow =null) {...

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>

Solutions

Expert Solution

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
&nbsp;second &nbsp;&nbsp;&nbsp; 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....


Related Solutions

QUESTION 1 Consider the following program: var x = 0; function sub1() {    var x =...
QUESTION 1 Consider the following program: var x = 0; function sub1() {    var x = 1;    function sub2() {       function sub3() {          print x;       }       sub3();    }    function sub4() {       var x = 2;       sub2();      }    sub4(); } sub1(); If this code uses static scoping, when it is executed what is printed? 0 1 2 QUESTION 2 Consider the following program: var x = 0; function sub1() {    var x = 1;    function sub2() {       function sub3() {          print...
Each of the following pairs of null and alternative hypothesis has some error. Identify the error...
Each of the following pairs of null and alternative hypothesis has some error. Identify the error and explain how to fix it. H0: The average ‘freshness’ of an edible food arrangement is at least 3 hours H1: The average ‘freshness’ of an edible food arrangement is not 3 hours H0: The average ‘freshness’ of an edible food arrangement is more than 3 hours H1: The average ‘freshness’ of an edible food arrangement is less than 3 hours H0: The average...
State the Null and Alternative Find The Standard error and Test statistics (show work for credit...
State the Null and Alternative Find The Standard error and Test statistics (show work for credit ) include the decoding. Draw the standard normal Distribution and decide how likely is the test statistics. Decide to reject or accept the Null hypothesis ~ Use the Test statistics and or the p-value. Show or describe where did you get the p-value if use it. Conclusion 1) One study found that 52% of women with breast cancer experience optimism, social support, spirituality. A...
State the Null and Alternative Find The Standard error and Test statistics include the decoding. Draw...
State the Null and Alternative Find The Standard error and Test statistics include the decoding. Draw the standard normal Distribution and decide how likely is the test statistics. Decide to reject or accept the Null hypothesis ~ Use the Test statistics and or the p-value. Show or describe where did you get the p-value if use it. Conclusion It is claimed that 6% of the population in a specific village suffer from a certain rare eye disorder. However, the doctor...
What is invalid about each of the following program? Fixed the error once you find it....
What is invalid about each of the following program? Fixed the error once you find it. (You may find more than one errors in the code.) Question #include <iostream> #include <iomanip> using namespace std; class B { protected: virtual void func1() { cout << "base:" << endl; } }; class D1 : public B { void func1() { cout << "D2:" << endl; } }; class D2 : public B {}; int main() { B Bobj; D1 Dobj; B* p...
Chapter 9 (Pointers) - Review Questions Find the Error Each of the following definitions and program...
Chapter 9 (Pointers) - Review Questions Find the Error Each of the following definitions and program segments has errors. Locate as many as you can. 46. int ptr* = nullptr; 47. int x, *ptr = nullptr; &x = ptr; 48. int x, *ptr = nullptr; *ptr = &x; 49. int x, *ptr = nullptr; ptr = &x; ptr = 100; //Store 100 in x cout << x << endl; 50. int numbers[] = {10, 20, 30, 40, 50}; cout <<...
      Show that     Var(x-a/)=1/h^2 Var(x)
      Show that     Var(x-a/)=1/h^2 Var(x)
A Type 1 error is defined as: Rejecting a False Null Hypothesis Rejecting a True Null...
A Type 1 error is defined as: Rejecting a False Null Hypothesis Rejecting a True Null Hypothesis Failing to Reject a False Null Hypothesis Failing to Reject a True Null Hypothesis b.) The probability for which a Type 1 error may occur in a hypothesis test is referred to as: Z-value Test Statistic Critical Value Level of Significance c.) A researcher conducts a hypothesis test to evaluate the effect of a treatment. The hypothesis test produces a z-score of z...
Standard Costing Questions Price var = 25 fav , quant var = 19 unf . Find...
Standard Costing Questions Price var = 25 fav , quant var = 19 unf . Find the total var (indicate dollar amount and fav or unf) Stand hrs x Stand rate = 300 ; Act hrs X Act rate= 350 ; price var= 60 unfav. Find the quant variance ( indicate $ amount and if fav or unf)     Standard per suit is 8 hours @ 8 per hour . Made 10 suits. Used 85 hours @ 7 per hour    36A)...
E(Y) = 4, E(X) = E(Y+2), Var(X) = 5, Var(Y) = Var(2X+2) a. What is E(2X...
E(Y) = 4, E(X) = E(Y+2), Var(X) = 5, Var(Y) = Var(2X+2) a. What is E(2X -2Y)? b. What is Var(2X-Y+2)? c. What is SD(3Y-3X)? 2) In a large community, 65% of the residents want to host an autumn community fair. The rest of the residents answer either disagree or no opinion on this proposal. A sample of 18 residents was randomly chosen and asked for their opinions. a) What is th probability that the residents answer either disagree or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT