Introduction
Learn JS Today is your resource for taking your first steps in your journey to
JavaScript knowledge. We have curated resources for your personal betterment.
Functions
A JavaScript function is a block of code designed to perform a particular task.
That task could be anything like completing some sort of mathematical equation,
displaying information, or making some animation occur. You can set parameters to
the function to call them.
function multiplyThat(firstNumber, secondNumber) {
return firstNumber * secondNumber;
}
console.log(multiplyThat(3,5));
Objects
A JavaScript object is a collection of properties that make up the whole. For example,
a car has multiple different pieces that fit together to make up the whole vehicle.
Contents of an object will always be found within {}.
let car = {
make: 'Nissan',
model: 'Pathfinder',
year: 1998,
color: 'Green',
name: 'Alice',
beautiful: true
}
console.log(car.name);
Arrays
A JavaScript array holds information of any type. You can view information in a array by
indexing it. To find the contents of an array, it's helpful for you to know that arrays
begin at 0, not 1.
let cats = ['Beans', 'Gravy', 'Rupert', Zola, 'Loumi'];
console.log(cats[0]);
For Loops
A For Loop in JavaScript loops through code for as many times as you want. As long
as the conditions are still true, it will keep looping. It is possible to have an
infinite loop, but no one needs that kind of negativity in their life.
for (i = 0; i <= 5; i++) {
console.log("The number is " + i);
}
Conditionals
A Conditional Statement in JavaScript will do different things depending on the
different conditions. If the condition is true, it will perform the specified
action. If the condition is false, it will carry on to the next condition. If
there are no more conditions, there may be an else statement to specify what to
do if none of the conditions are true.
let favShow = "Parks and Rec";
if(favShow == "Great British Baking Show") {
console.log("No soggy bottoms here!");
} else if(favShow == "Parks and Rec") {
console.log("Bye bye, Li'l Sebastian!");
} else {
console.log("Your favorite show isn't as good");
}
Summary
In summary, JavaScript is as difficult as you make it. As soon as you understand some
concepts, it is easy to delve deeper and learn more new things. JavaScript is always
changing and becoming better. In order to stay relevant, you need to always be learning
and challenging yourself.