xxxxxxxxxx
function calculateSum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(calculateSum(numbers)); // 6
xxxxxxxxxx
function calculateSum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(calculateSum(numbers)); // 6
xxxxxxxxxx
function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(numbers));
// expected output: 6
console.log(sum.apply(null, numbers));
// expected output: 6
xxxxxxxxxx
//The spread operator[...arr] takes all the values of an array and returns them
const arr = [1,2,3]
//below another array is created and the all the values of 'arr' are passed in
const arr2 = [arr,4,5]
//also 4,5 are added to the new arr2
//The spread operator also allows us to convert a node list into a regular array
const selectedItems = document.querySelectorAll('.itemsWithThisClass');
//this can be usefull when manipulating the DOM
const convertedNodeToArray = [selectedItems]
xxxxxxxxxx
function calculateSum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(calculateSum(numbers)); // 6
xxxxxxxxxx
function calculateSum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(calculateSum(numbers)); // 6
xxxxxxxxxx
function calculateSum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(calculateSum(numbers)); // 6
xxxxxxxxxx
function calculateSum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(calculateSum(numbers)); // 6
xxxxxxxxxx
// Define a function with three parameters:
function myBio(firstName, lastName, company) {
return `${firstName} ${lastName} runs ${company}`;
}
// Use spread to expand an array’s items into individual arguments:
myBio( ["Oluwatobi", "Sofela", "CodeSweetly"]);
// The invocation above will return:
“Oluwatobi Sofela runs CodeSweetly”