Class 29 Flashcards
What is a program?
A set of instructions that you write to tell a computer what to do
What is a programming?
A task of writing instructions in a language that computer can understand
What does variables do?
Store information
How to create/declare a variable?
Use the keyword “let”
Conditional syntax
if (condition is true) {
//do this
else if (….) {
//do that
else {
// do this then
}
Multiple conditions (and)
if (name === “Leon” && status === “Balling”) {
do this
}
Multiple conditions (or)
if (day === “Saturday” || day === “Sunday”) {
It is the weekend
}
What are functions?
Reusable sets of instructions
Functions
function yell (word) {
alert(word)
}
yell(“Hello”)
What are loops?
Repeat an action some number of times
What are 3 main types of loops in js?
For, while and do while loops
For loop
for (let i = 1; i < 5; i++) {
console.log(i)
}
In order to create function in js, what keyword do you need?
function
Ex.
function toCelsius(temp) {
… }
What are arrays?
A data structure to store ordered collection
Array elements are numbered starting with zero
Arrays have many methods to manage the order of elements
Arrays are populated with any type of elements (string, boolean or number)
How to create arrays?
Through literal notation or a constructor