Working with Variables and Data in JavaScript (Exercise)

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which operator denotes that the left operand should not equal the right operand?

!=

Consider the following expression: x = 25; y = 10; z = 35; Which statement would evaluate to false?

(x < y) && (y < z);

You have defined two variables as follows: var x = 10; var y = "5"; You add the following operation to your script: alert(x+y); When you run this script in the browser, what result will appear in the alert box?

105

Which line of code implements inline scripting?

<input type="button" value="Click Here!" onclick="this.value='Thanks!'"/>

What is null?

A keyword for the null value, which is no value

Consider the following code: <script type="text/javascript"> var message = "Hello ",message2 = "World"; document.write(message + message2); </script> What will be the result of this script when run in the browser?

Hello World

Consider the following code: weather = confirm("Click OK if it is raining" ); alert("I looked outside and the weather report is " + weather); What is a possible result from this code when it is run in the browser?

I looked outside and the weather report is true

Consider the following: if, this, var These are all examples of what?

JavaScript keywords

Consider the following line of code: parseInt("C"); What would be the result of this code?

NaN

Which variable data type can consist of any series of alphanumeric characters?

String

How does the confirm() method differ from prompt() and alert()?

The confirm() method returns a value of true or false, whereas prompt() and alert() do not.

What does the operator === mean?

The operands on either side are equal in both value and data type.

How does the prompt() method differ from alert() and confirm()?

The prompt() method allows for user-typed input, whereas confirm() and alert() do not.

Consider the following code: var streetLight = 'Green'; var drive = (streetLight !== 'green') ? "go" : "stop"; alert("The street light says " + drive); What will the alert box display when this script is run in the browser?

The street light says go

Consider the following code: var streetLight = 'green'; var drive = (streetLight !== 'green') ? "go" : "stop"; alert("The street light says " + drive); What will the alert box display when this script is run in the browser?

The street light says stop

Consider the following code: var streetLight = 'red'; var drive = (streetLight == 'red') ? "stop" : "go"; alert("The street light says " + drive); What will the alert box display when this script is run in the browser?

The street light says stop

Consider the following code: firstNumber = prompt("Enter a number" , ""); secondNumber = prompt("Enter another number" , ""); alert("The sum of your two numbers is " + (firstNumber + secondNumber)); Assume that the user inputs the numbers 2 and 3 when she runs the script in the browser. What is a possible result from this script?

The sum of your two numbers is 23

Consider the following code: var petName = prompt("What is your pet's name?", " "), petType = prompt("What type of animal is your pet?", " "); var i = petName + " is a " + petType + "." ; Susan enters input for her cat, Sampson. What is the value of i after she runs this script in her browser?

The value of i will be: Sampson is a cat.

Which variable data type is a variable that has not yet had a value assigned to it?

Undefined

Consider the following code: <script type="text/javascript"> function ClientMessage() { var message="Hi there!"; alert(message); } </script> What is the expected outcome if the preceding function is called from an onclick event in the <body> tag?

When you click on the document body, the message is displayed.

Assume that the following code is placed in the <head> tag: <script type="text/javascript"> function DisplayName(){ var YourName = window.prompt("What is your name?","Please enter your name"); document.write("Hello " + YourName); } </script> What is necessary for this script to write the text to the document?

You must add a call to the function in the body.

Which of the following is a method of the window object?

alert

Which of the following is a reserved word in JavaScript?

interface

Which of the following is a valid variable name in JavaScript?

sink

Which of the following is NOT a valid variable name in JavaScript?

this

Which code will correctly declare the EmployeeID variable as a number data type?

var EmployeeID = 123;

Which example demonstrates correct syntax for declaring a variable?

var _LAST_name;

Which example demonstrates correct syntax for declaring a string variable?

var _greeting;

Which code will correctly declare the blueSky variable as a Boolean data type?

var blueSky = true;

Which code will correctly declare the calendarYear variable as a date object?

var calendarYear = new Date();

What is the default object in the JavaScript Document Object Model?

window

Consider the following expression: x = 25; y = 10; Which statement would evaluate to true?

x > = y;

Which JavaScript operator means OR?

||


संबंधित स्टडी सेट्स

Chapter 53: Airway Management Application Exercise

View Set

Chapter 17 - Governance and Structure

View Set

MCB2004L Exercise 11 (Microbial production of Yogurt/Sauerkraut)

View Set