Es 6
Es 6
Problem Statement:
Create two variables using let and const. The let variable should be
named age and set to 30. The const variable should be named name
and set to "Alice". Try to reassign the name variable and observe what
happens.
Hint/Explanation:
ES6 introduced let and const for declaring variables. let is used for
variables that can change, while const is for variables that should
remain constant.
Solution:
Problem Statement:
function add(a, b) {
return a + b;
Hint/Explanation:
Arrow functions provide a concise syntax and lexically bind the this
value.
Solution:
Problem Statement:
Use a template literal to print "Hello, Alice! Your age is 30." using the
variables name and age.
Hint/Explanation:
Template literals allow embedded expressions and multi-line strings.
Solution:
Problem Statement:
Hint/Explanation:
Solution:
Problem Statement:
Solution:
Problem Statement:
Combine two arrays [1, 2, 3] and [4, 5, 6] into a new array using the
spread operator.
Hint/Explanation:
Solution:
Problem Statement:
Write a function that takes multiple arguments and returns their sum
using rest parameters.
Hint/Explanation:
Solution:
Problem Statement:
Hint/Explanation:
Solution:
const greet = (name, greeting = "Hello") => ${greeting}, ${name}!;
Problem Statement:
Hint/Explanation:
Solution:
class Animal {
constructor(name) {
this.name = name;
bark() {
Problem Statement:
Hint/Explanation:
Solution:
console.log(result);
}
run();