Javascript is a scripting language which is used to interaction
syntax: condition:true statement : false statement
const age = 88;
age >= 18 ? console.log("you can") :console.log("you wont ");
const firstname = "Sathiya";
const firstname1 = "SathiyaPriyan";
const $new = `${firstname} is a guy `;
console.log($new);
<script src="index.js"></script>
"use strict";
// Function declaration
function calAge1(birthYear) {
const age = 2029 - birthYear;
return age;
}
console.log(calAge1(2003));
// Anonymous function - expressions is a vaule
const me = function (birthYear) {
const age = 2029 - birthYear;
return age;
};
// and it's called the object literal Syntax
const spObject = {
firstName: "sathiya",
lastName: "sp",
age: 27,
destinitation: "student",
habits: ["productivity", "time management"],
};
===) compares two values without type coercion==) compares values with type coercion in JavaScript.is full of really weird rules and behaviors. this can introduce many hard
syntax : let func = (arg1, arg2, ..., argN) => expression
It is introuded in ES6 vesrion
const yearsfa = [1991, 2007, 1967, 2020];
const age = [];
const newArray = [];
function calAge($var) {
return 2023 - $var;
}
for (let count = 0; count <= years.length; count++) {
console.log((age[count] = calAge(years[count])));
newArray.push(age);
}
console.log("--");
console.log(newArray);
console.log(calAge(2003));
for (let count = 0; count < array.length; count++) {
const element = array[count];
}
const $colour = prompt(`Tell your
most favourate colour`);
console.log($colour);
function cutFruit(fruit) {
return fruit * 4;
}
function fruitProcessor(apples, oranges) {
const appleP = cutFruit(apples);
const orangesP = cutFruit(oranges);
const juice = `Juice with ${apples} apples and ${oranges} oranges`;
return juice;
}
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.