JS
JS AGAIN
SYNTAX
CODE CHALLENGE
YOUR AWESOME TA
100
You use this to create a container in JavaScript
What is the var keyword?
100
These two are commonly known methods for finding HTML elements
What is getElementByID(); and getElementsByTagName();
100
The values of x, y and z after the execution of the three lines of code below: var x = 5, y = 6, z; x = y++; z = ++y;
What is x equals 6 and y equals 7 (after the x = y++ statement), and z equals 8 and y equals 8 (after the z = ++y statement)?
100
Given... done = (5 > 0); The value of done.
What is true?
100
Your TA worked for this globally known company at the age of 19.
What is Microsoft?
200
These are all operators used for equality testing.
What is ! / || / && / ===
200
A single variable that holds multiple valuse
What is an array?
200
Given... scores = {8.5, 7.2, 9.9, 6.8}; The value of score.length + 38;
What is 42?
200
Create the code that builds the array 0,1,2,3,4,5,6,7,8,9 one element at a time, and then displays the result in an alert window.
What is the following? result = []; for (i = 0; i <= 9; i++) { result[i] = i; } alert(result);
200
This is your TA's favorite TV show.
What is Game of Thrones/Walking Dead?
300
This is a function used to get input from the user
What is prompt();
300
Number, String, Boolean, Object, Function
What are the 6 fundamental data types?
300
Given the following code for( var i = 0; i > 100; i++) { //Do something } The syntax errors here cause this
What is an infinite loop?
300
Code Challenge! Create a script that takes in 2 values, a userName and Password, compares it to a store username and password and returns ACCESS GRANTED in green if correct or ACCESS DENIED in red if otherwise.
var password = "password"; var userName = "admin"; var userNameInput = prompt("Enter Username"); var userPassInput = prompt("Enter Password"); switch (userNameInput, userPassInput) { case password,userName: console.log("ACCESS GRANTED"); break; default: console.log("ACCESS DENIED"); }
300
Your TA has a favorite one of these that he wears at least one of everyday.
What is a hat?
400
These 3 functions are considered dialog boxes to interact with a user on a web page.
What is prompt(); , alert(); , confirm();
400
This function gives you a random number.
What is Math.random();?
400
Given the following code var outter; function test(param1, param2){ //code } The variable outter is able to be used anywhere in the code, but param1 and 2 are not. One thing causes this.
What is scope?
400
Code Challenge! A script that takes in a lowercase string and returns it with the first letter capitalized
function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); }
400
This is your TA's favorite soda (If you answer this you have to go get me one EASY POINTS THOUGH)
What is Mountain Dew?
500
Code Challenge! Write a program that creates an empty array and assigns the numbers 1-100 to the array. No hard coding!
var myArray = array[]; for(var i = 1; i <= 100; i++); { myArray.push(i); }
500
This function sorts an array "myArray" alphabetically in ascending order
What is myArray.sort();?
500
It is a best practice to use "===" instead of "==" in order to avoid this.
What is automatic type conversion?
500
Create the code that takes three(3) pieces of information from a user, 2 Numbers and an Operator, and performs whatever operation given.
What is is the following? var userVal1 = Number(prompt("enter value 1")); var userVal2 = Number(prompt("enter value 2")); var usrOperator = prompt("enter the operator"); switch (usrOperator) { case '+': console.log(userVal1 + userVal2); break; case '-': console.log(userVal1 - userVal2); break; case '/': console.log(userVal1 / userVal2); break; case '*': console.log(userVal1 * userVal2); break; default: console.log("error: bad input"); }
500
This is your TA's favorite food.
What is a taco?
M
e
n
u