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
function shouter(whatToShout) { | |
return whatToShout.toUpperCase() + "!!!"; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! |
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
function computeArea(width, height) { | |
return width * height | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! |
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
function doTrafficLights() { | |
turnOffLights(); | |
var activeLight = getActiveLight(); | |
if (activeLight === 'red') { | |
turnRed(); | |
} | |
if (activeLight === 'yellow') { | |
turnYellow(); | |
} | |
if (activeLight === 'green') { |
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
function accessFirstItem(array) { | |
return array[0] | |
} | |
function accessThirdItem(array) { | |
return array[2] | |
} | |
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
function average(numbers) { | |
var total = numbers[0]; | |
for (var i=1; i < numbers.length; i++) { | |
total+= numbers[i]; | |
} | |
return total/numbers.length; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) |
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 scope? Your explanation should include the idea of global vs. local scope. | |
The scope is what you are able to access within a group of code. Global scope refers to variables that are accessible everywhere, while the local scope is more specific. For example, if a variable is defined within a function, it is local to that function and no where outside of it. However, if a variable is defined outside of this function, it is global and you are able to access it in multiple functions. | |
Why are global variables avoided? | |
Global variables make unintended side effects in a program more likely, meaning it will be harder to track down bugs in your code. There is just one global scope as opposed to the many local scopes that can be created (and bugs that can avoided from these multiple scopes). | |
Explain JavaScript's strict mode |
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
function keyDeleter(obj) { | |
delete obj.foo; | |
delete obj.bar; | |
return obj; | |
} | |
var sampleObj = { | |
foo: 'foo', | |
bar: 'bar', |
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
var studentData = [ | |
{ | |
name: 'Tim', | |
status: 'Current student', | |
course: 'Biology' | |
}, | |
{ | |
name: 'Sue', | |
status: 'Withdrawn', | |
course: 'Mathematics' |
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
function getTokens(rawString) { | |
// NB: `.filter(Boolean)` removes any falsy items from an array | |
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort(); | |
} | |
function mostFrequentWord(text) { | |
//this is saying we will use a function called mostFrequentWord that will have text as its only parameter | |
var words = getTokens(text); | |
//now we are making a variable called words that will basically be the getTokens function |
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
function handleBulbClicks() { | |
$('.lightbulb').click(function(event){ | |
$('.lightbulb').removeClass('bulb-on') | |
$(event.currentTarget).addClass('bulb-on') | |
}); | |
} | |
$(function() { | |
handleBulbClicks(); | |
}); |
OlderNewer