Last active
August 29, 2015 14:24
-
-
Save nolds9/c93a94769c5f46be3785 to your computer and use it in GitHub Desktop.
JavaScript Basic HW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
typeof( 15 ); | |
* 'number', 15 is an integer. | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
typeof( "hello" ); | |
*'String'', there are characters between quotes. | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
typeof( [ "dog", "cat", "horse" ] ); | |
* It would return 'array' because it is a list of value, in this case strings. | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
typeof( NaN ); | |
* It would return 'number' because NaN is somehow a number? Why Javascript? | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
"hamburger" + "s"; | |
* It would return "hamburgers" as we are concatenating two strings | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
"hamburgers" - "s"; | |
* It would return NaN because there is no way to subtract strings. | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
"johnny" + 5; | |
*Returns "Johnny5" because of type coercion. | |
// What is the return value of the below code sample? Provide a sentence or two of explanation. | |
99 * "luftbaloons"; | |
* Returns NaN because in JS a string may not be multiplied. | |
// What will the contents of the below array be after the below code sample is executed. | |
var numbers = [ 2, 4, 6, 8 ]; | |
numbers.pop(); | |
numbers.push( 10 ); | |
numbers.unshift( 3 ); | |
*numbers = [3, 2, 4, 6, 10]; | |
// What is the return value of the below code sample? | |
var morse = [ "dot", "pause", "dot" ]; | |
var moreMorse = morse.join( " dash " ); | |
moreMorse.split( " " ); | |
*will return an array with ["dot", "dash", "pause", "dash", "dot"] | |
// What will the contents of the below array be after the below code sample is executed. | |
var bands = []; | |
var beatles = [ "Paul", "John", "George", "Pete" ]; | |
var stones = [ "Brian", "Mick", "Keith", "Ronnie", "Charlie" ]; | |
bands.push( beatles ); | |
bands.unshift( stones ); | |
bands[ bands.length - 1 ].pop(); //pete is gone | |
bands[0].shift(); //brian is gone | |
bands[1][3] = "Ringo"; | |
bands = [["Mick","Keith","Ronnie", "Charlie"]["Paul", "John", "George", "Ringo"]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment