Day 6 — declarations, arrows, defaults

Lesson

Topic 1 Part 1
function add(a,b) {
    console.log(a+b);
}
add(2,3);

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 2 Part 2
function xyz() {
    console.log("hi");
}
const x = xyz();
console.log(x);

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 3 Part 3
const greet = function(xyz) {
    return "hello, " + xyz;
}

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 4 Part 4
console.log(greet("kalyan"));

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 5 Part 5
const add1 = (a,b) => {
    return a+b ;
}

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 6 Part 6
console.log(add1(1,1));

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 7 Part 7
const add2 = (a,b) => a+b;
console.log(add2(2,2));

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 8 Part 8
const square = x => x*x;
console.log(square(4));

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 9 Part 9
const greet1 = () => "hello";
console.log(greet1());

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 10 Part 10
console.log("-------------------------------------------------------")

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.

Section 11 Part 11
function greet2(name = "kalyan") {
    console.log(name);
}
greet2("xyz");
greet2();

Code below mirrors ../js/lesson.js. Open DevTools → Console to see output when the script runs.