Skip to content

Instantly share code, notes, and snippets.

const STORE = [
{
question: "Blood sugar is also known as:",
answer: "Glucose",
choices: ["Frutose","Glucose","Cellulose"],
},
{
question: "Food with a high glycemic index means:",
answer: "it contains alot of glucose.",
choices: ["it contains alot of glucose.","there is a net amount of glucose.","there is a high amount of fat."],
function handleNewItemSubmit() {
// this function will be responsible for when users add a new shopping list item
// find input field and take the value from it
// add event listener; when the button 'submit' is clicked, the string in the input box will be stored as a value
// field input should clear once submit button is clicked
// call generateShoppingItemsString that will append and render to the DOM
console.log('`handleNewItemSubmit` ran');
}
@josno
josno / 11_Variable Scope Answers
Last active May 12, 2019 12:28
Answers to Javascript modue - Variable Scope Lesson
What is scope? Your explanation should include the idea of global vs. block scope.
Scope in Javascript, refers to how a declared variable can be accessed throughout your code. A global variable has a 'global scope' that can be accessed wherever in the code because it's attached to the root of the file. A block variable with 'block scope' can only be accessed within its own block. For instance, a variable declared inside a function - which would be considered a block - can only be accessed inside that function block.
Why are global variables avoided?
Global variables can overwrite other variables throughout your code. When there are also multiple Javascript files that run in a web page, any global variables that have the same name can overwrite each other, causing functions and overall code to break down. Essentially, our code would not work properly.
Explain JavaScript's strict mode.
The strict mode in Javascript makes sure that your code is written as explicitly and as clean as possible. If you're