Functions
function fullName (firstName, lastName) {
return firstName + lastName;
}
console.log(fullName("John", " Doe"));
A JavaScript function
is a block of code designed to perform a task. These are pieces of data that we declare to use later.
functions
are executed when they are called. This is known as invoking a function. Functions always return
a value.
in JavaScript, if no return
value is specified, the function
will return
undefined. functions
are Objects.
Here is an informational video about Functions
Objects
let garden = {
vegetable: 'zucchini',
sun: true,
size: 10
};
console .log(garden.vegetable)
A JavaScript object literal is a comma-separated list of name-value pairs wrapped in curly braces. Object literals encapsulate
data, enclosing it in a tidy package. This minimizes the use of global variables which can cause problems when combining.
code. Object literal property values can be of any data type, including array literals, functions, and nested object literals.
Here is a video with more information about Objects
Conditionals
let isOn = true;
if (isOn == true) {
console .log('The Light is On!')
};
Using a conditional, like an if statement, allows us to specify that a certain block of code should be executed if a certain
condition is met. In this example we have a variable called "isOn". If this variable equals to true, the system should output
"The Light is On!'.