- No notes were taken
- No notes were taken
- Looks like convention in JavaScript is to use single quotes.
- No notes were taken
- JavaScript has a
.replace()
method that takes two arguments. The first argument is an existing substring and the second is the string that will replace it.
- No notes were taken
- To round numbers in JavaScript we use the
Math
object along with the.round()
method and pass it in the float we want rounded.
- We use the
.toString()
method to convert a number to a string.
- No notes were taken
- No notes were taken
- No notes were taken
- We use the
.filter()
method to filter an array based on a condition.
var filtered = numbers.filter(function(num) {
return num % 2 === 0;
});
- No notes were taken
- No notes were taken
- No notes were taken
- No notes were taken
- No notes were taken
- No notes were taken
- Scope is the set of variables, objects, and functions you have access to.
- JavaScript has two scopes: global and local.
- A variable that is declared outside a function definition is a global variable, and its value is accessible and modifiable throughout your program.
- A variable that is declared inside a function definition is local. It is created and destroyed everytime the function is executed, and it cannot be accessed by any code outside the function.
- Functions defined inside other functions, known as nested functions, have access to their parent function's scope.
- IIFE, Immediately Invoked Function Expression, is a common pattern for creating local scopes.
(function() {
})();