Each of these can be accomplished with one line of javascript.
- Create a variable and assign it the value
explore
(a string). - Create a variable that's an array of two values (strings),
red
andblue
. - Create a variable that evaluates to the boolean true. Create another var, set it to 1. Compare the two (with javascript) and tell me whether javascript thinks they equal each other.
- Write a function named
my_first_function
that logs to console the word "hey". Name the functionmy_first_function
. That line will start withfunction my_first....
- Edit that function so instead of logging to console, it "returns" the value "hey" ("return" is the name of the command you can use in a function that sends information back to whatever called the function). Call (run) the function and make sure it does what you think it does.
- Take your function from before and assign it to a variable named
hey_maker
. That line will start withvar hey_maker....
Call it from the javascript console. - Write a function that, depending on what value is passed the function, returns whatever's passed the function and appends the word "hey" to the end of it.
- Create a variable and assign it a value of 17 (the integer, not the string). Divide it by 5 and then round the result to the nearest whole number.
- This is a three-parter:
- Create a variable that's an object and give it a key of
color
, and give that key a value ofgrey
(a string). - Add another key to the object, call the key 'size' and assign the key an empty array.
- Write a line of js that returns all the keys of that object.
- Create a variable that's an object and give it a key of
- Create a variable and give it a value of a function that returns the value 193 (an integer), then run that function.
- Create a variable and set it to
true
(a boolean). Write an if statement that tests if that variable is true, and if it is, write to the console log the value of that variable. - Create a variable, assign it the integer 3, and write a while loop that increases the value of that variable by 1 until that var equals 10.
- Write a for loop that loops five times, logging to console the variable you use to count each time.
- Write a for loop that loops 10 times, logging to console the counter variable only when the counter variable is divisible by 3.
- Create an array with three items, then create another variable that gets its value from whatever's the last element on that array you created.
- Create an array, and then reverse its contents.
- Create a variable with that's a string that's assigned a value of this sentence itself. Create another variable that's assembled programmatically and is an array made up of each of the words of that sentence.
- Using the array you created in the previous quiz, test to see if the word "assigned" is in that array, and if it is, log all the words after the word "this" to console.
- Write a line of javascript that when executed in the javascript console, gives the entire page you're on a 50px black border.
- Write some javascript that turns the text color of every
<p>
on the page you're on red. - Find three functions available to the document object and report back with the function names & what each does.
- Turn this string into a javascript Date object: 'June 1 2017 00:00:00 GMT-06:00'
- Calculate the number of seconds since the June 1, 2017.
- Write a function that logs the time to the console every five seconds.
- Write a function that counts down from 10 to 0, once per second, logging each new number to console. When you get to zero, send the console an error message instead of a log message.
- Write a function that counts down from 10 to 0, once per second, appending each new number to an array that you have created. When you get to zero log the array to console.
- Given this array,
var words = ['hi', 'this', 'is', 'an', 'array', 'of', 'some', 'words'];
, loop through it and add any words that have the letter "h" in them to another, separate array. Log that array to the console when you're done. - Write javascript that turns this string into a JSON object: ``.
. Write some javascript that appends this script to the head element of the page you're on:
http://interactive.nydailynews.com/js/jquery.min.js