click below
click below
Normal Size Small Size show me how
CIS-131 Cert Study
CIS-131 Cert Study Guide
Question | Answer |
---|---|
Inside which HTML element do we put the JavaScript? A) <script> B) <javascript> C) <js> D) <scripting> | A |
What is the correct JavaScript syntax to change the content of the HTML element below? <p id="demo">THis is a demo</p> A) document.getElementByName("p").innerHTML = "Hello World!"; B) document.getElementById("demo").innerHTML = "Hello World!"; | B |
Where is the correct place to insert JavaScript? A) In the <head> section B) In the <body> section C) Either the <head> or the <body> section D) None of the above. JavaScript is inserted in a separate file | C |
What is the correct syntax for referring to an external script called "xxx.js"? A) <script name="xxx.js"> B) <script src="xxx.js"> C) <script href="xxx.js"> D) <script file="xxx.js"> | B |
The external JavaScript file must contain the <script> tag | False Explanation: The external JavaScript file should not contain the <script> tag. The <script> tag is |
How do you write "Hello World" in an alert box? A) alertBox("Hello World"); B) msg("Hello World"); C) msgBox("Hello World"); D) alert("Hello World"); | D |
How do you create a function in JavaScript? A) function = myFunction() B) function:myFunction() C) function myFunction() D) function myFunction() {} | D |
How do you call a function named "myFunction"? A) myFunction(); B) call myFunction(); C) call function myFunction(); D) run myFunction(); | A |
How do you write an IF statement in JavaScript? A) if (i == 5) then B) if i = 5 C) if i == 5 then D) if (i == 5) | D |
How do you write an IF statement for executing some code if "i" is NOT equal to 5? A) if i <> 5 B) if (i != 5) C) if i =! 5 D) if (i !== 5) | B |
How does a WHILE loop start? A) while i = 1 to 10 B) while (i <= 10) C) while (i <= 10; i++) D) while i <= 10: | B |
How does a FOR loop start? A) for (i <= 5; i++) B) for (i = 0; i <= 5) C) for i = 1 to 5 D) for (i = 0; i <= 5; i++) | D |
How can you add a single-line comment in JavaScript? A) <!--This is a comment--> B) //This is a comment C) /*This is a comment*/ D) comment: This is a comment | B |
How can you add a multi-line comment in JavaScript? A) <!--This is a comment--> B) //This is a comment C) /*This is a comment*/ D) comment: This is a comment | C |
What is the correct way to write a JavaScript array? A) var colors = "red", "green", "blue"; B) var colors = (1:"red", 2:"green", 3:"blue"); C) var colors = ["red", "green", "blue"]; D) var colors = 1=("red"), 2=("green"), 3=("blue"); | C |
How do you round the number 7.25 to the nearest integer? A) Math.rnd(7.25) B) round(7.25) C) Math.round(7.25) D) rnd(7.25) | C |
How do you find the number with the highest value of x and y? A) Math.ceil(x, y) B) top(x, y) C) ceil(x, y) D) Math.max(x, y) | D |
What is the correct JavaScript syntax for opening a new window called "OTC" that opens in a new tab to "otc.edu"? A) window.newTab("otc.edu", "OTC"); B) window.open("otc.edu", "OTC", "_blank"); C) window.open("otc.edu", "OTC"); | C |
JavaScript is the same as Java | False |
How can you detect the client's browser name? A) navigator.browserName B) client.browser.name C) navigator.appName D) browser.name | C |
How do you declare a JavaScript variable? A) new variableName; B) let variableName; or var variableName; C) variableName = value; D) variable variableName; | B |
In JavaScript,difference between let and var? A) let is block-scoped, while var is function-scoped. B) var is block-scoped, while let is function-scoped. C) There is no difference between let and var. | A |
How do you declare a JavaScript constant? A) const constantName = value; B) var constantName = value; C) let constantName = value; D) constant constantName = value; | A |
How do you declare a JavaScript function? A) function = myFunction() {} B) let myFunction() {} C) var myFunction = function() {} D) function myFunction() {} | D |
How do you declare a JavaScript class? A) class = myClass {} B) var myClass = class {} C) function myClass() {} D) class myClass {} | D |
What will the following code return: Boolean(10 > 9)? | True |
How do you write to a JSON file with JavaScript? A) JavaScript cannot write to a file directly B) Use the fs.writeFile() method in Node.js C) Use the JSON.stringify() method to convert the data to JSON format | B |
Which of the following is properly formatted JSON? A) {name: "John", age: 30} B) {"name": "John", "age": 30} C) ('name': 'John', 'age': 30) D) [name: "John", age: 30] | B |
JavaScript is case-sensitive | True |
What is asynchronous programming in JavaScript? A) Running multiple threads simultaneously B) Executing code in sequence, one after the other C) Running code simultaneously without blocking the execution of other code | C |
Which of the following is NOT a method for working with arrays in JavaScript? A) slice() B) splice() C) push() D) reverse() | C |
What is the purpose of the try...catch statement in JavaScript? A) To execute code in a loop B) To handle errors and exceptions C) To declare a new variable D) To create a new function | B |
What is a closure in JavaScript? A) A function that returns another function B) A way to create private variables and methods in a function C) A way to stop code execution D) A method for iterating over an array | B |
Which of the following is NOT a decision statement in JavaScript? A) if...else B) switch...case C) ternary operator D) for...in loop | A |
What is a promise in JavaScript? A) A way to handle errors and exceptions B) A method for working with data collections C) A way to work with asynchronous code D) A method for iterating over an array | C |
Which of the following is NOT a way to work with variables, operators, and expressions in JavaScript? A) let B) const C) var D) function | A |
What is a prototype in JavaScript? A) A function that creates new objects B) A way to extend the properties and methods of an object C) A method for working with data collections D) A way to handle errors and exceptions | B |
What is the purpose of the JQuery library in JavaScript? A) To handle errors and exceptions B) To work with asynchronous code C) To simplify HTML document traversal and manipulation, as well as event handling and animation | C |
What is the purpose of data validation in JavaScript? A) To execute code in a loop B) To handle errors and exceptions C) To ensure that data is correct and useful D) To create new functions | C |