Thinkful List Template ('-' * 22)
Forked from Martin's Pen Thinkful List Template.
A Pen by Bryan Swagerty on CodePen.
Thinkful List Template ('-' * 22)
Forked from Martin's Pen Thinkful List Template.
A Pen by Bryan Swagerty on CodePen.
A Pen by Bryan Swagerty on CodePen.
$(document).ready(function() { | |
var DEBUG_MODE = true; | |
// Question class constructor | |
var Question = function (questionNumber, question, answer1, answer2, answer3, answer4, correctAnswer) { | |
this.questionNumber = questionNumber; | |
this.question = question; | |
this.answers = [answer1, answer2, answer3, answer4]; |
$(function(){ | |
$('#query').submit(function(event) { | |
event.preventDefault(); | |
var searchTerm = $('#search-term').val(); | |
var searchQuery = 'http://www.omdbapi.com/?s=' + searchTerm + 'r=json'; | |
console.log('Using query :' + searchQuery); | |
$.getJSON(searchQuery, function(data) { | |
showResults(data.Search); | |
}); |
Scope is the set of rules that apply to JavaScript variables regarding how they are declared and accessed. There are two kind of scope: Global scope and Function Scope or Local Scope. The preferred way to declare a variable in Javascript is using the keyword var
which keeps the variable from polluting the global scope. A function scope variable is declared in the function and not acccessible to any 'parent scope.' Failing to use var
during declaration can lead to unintended consesquences. It can cause bugs and make things more difficult to debug and collaborate on. For instance, a function should, given a set of inputs, always have the same output (a pure function). But this is not necessarily the case when variables cannot be consistently refrenced to (like with multiple functions using a global variable). To get around this, it is wise to use 'strict mode'
to prevent your code from compiling if there are any variables not using var.
Hoisting refers to how the JavaScript compiler looks up de
Object drills Lesson 6.2
API Capstone Ideas