Skip to content

Instantly share code, notes, and snippets.

@Curtismn87
Last active August 29, 2015 14:24
Show Gist options
  • Save Curtismn87/4b989ffb843cc67f7182 to your computer and use it in GitHub Desktop.
Save Curtismn87/4b989ffb843cc67f7182 to your computer and use it in GitHub Desktop.
// What is the return value of the below code sample? Provide a sentence or two of explanation.
typeof( 15 ); typeof lets you know what variable type of value you are entering. So this will return "number"
// What is the return value of the below code sample? Provide a sentence or two of explanation.
typeof( "hello" ); As stated before, this however will return "string"
// What is the return value of the below code sample? Provide a sentence or two of explanation.
typeof( [ "dog", "cat", "horse" ] ); As stated, before will be an object
// What is the return value of the below code sample? Provide a sentence or two of explanation.
typeof( NaN ); As stated, will return "number"
// What is the return value of the below code sample? Provide a sentence or two of explanation.
"hamburger" + "s"; ="Hamburgers" Will add the string "hamburger" to the string 's' and create one string
// What is the return value of the below code sample? Provide a sentence or two of explanation.
"hamburgers" - "s"; will return NaN because you cannot subtract a string from another string
// What is the return value of the below code sample? Provide a sentence or two of explanation.
"johnny" + 5; will return "Johnny5" since it is an addition operation with a string it will convert the number into a string and create a new string
// What is the return value of the below code sample? Provide a sentence or two of explanation.
99 * "luftbaloons"; will return NaN because you cannot multiply a number and a string
// What will the contents of the below array be after the below code sample is executed.
var numbers = [ 2, 4, 6, 8 ];
numbers.pop(); returns = 8
numbers.push( 10 ); returns = 5
numbers.unshift( 3 ); returns = 5
Executed at the same time returns = 5 this is because pop will remove a value, then push and unshift will add values. Each operation returns the length of the array
// What is the return value of the below code sample?
var morse = [ "dot", "pause", "dot" ];
var moreMorse = morse.join( " dash " );
moreMorse.split( " " );
returns = ["dot dash pause dash dot"] the var MoreMorse = will take all 3 objects from var morse, add " dash " in between each object
// 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 ); add var Beatles to bands var bands = [ "Paul", "John", "George", "Pete" ]
bands.unshift( stones ); add var stones to from two arrays in var bands = ["Charlie" "Paul", "John", "George", "Pete" ] [ "Brian", "Mick", "Keith", "Ronnie",]
bands[ bands.length - 1 ].pop(); removes "Pete" from (pop removes 1 at the end) var bands = [ "Brian", "Mick", "Keith", "Ronnie", "Charlie"] ["Paul", "John", "George",]
bands[0].shift(); this will remove "brian" (position 0 in the array) var bands = ["Mick", "Keith", "Ronnie", "Charlie"] ["Paul", "John", "George",]
bands[1][3] = "Ringo"; will add "Ringo" to the end of the second array because it is looking the position is 1,3 var bands = ["Mick", "Keith", "Ronnie", "Charlie"] ["Paul", "John", "George","Ringo"]
Comfort = 4
Completeness = 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment