UDR Assignment 1
UDR Assignment 1
Exercise 1
Rewrite the code below to use array destructuring instead of assigning each
value to a variable.
{
console.log("EXERCISE 1");
/**
Exercise 2
Rewrite the code below to assign each number to the right variable.
*/
{
console.log("EXERCISE 2");
/**
Exercise 3
console.log(name); // John
console.log(age); // 30
console.log(isAdmin); // false
console.log();
}
/**
Exercise 4
Rewrite the code below to use array destructuring instead of assigning each
value to a variable.
*/
{
console.log("EXERCISE 4");
/**
Exercise 5
Rewrite the code below to use array destructuring instead of assigning each
value to a variable.
Make sure not to have unused variables.
Hint:
https://untangled.io/in-depth-es6-destructuring-with-assembled-avengers
*/
{
console.log("EXERCISE 5");
/**
Exercise 6
Using Array Destructuring get the last name from the array.
Hint:
https://untangled.io/in-depth-es6-destructuring-with-assembled-avengers
*/
{
console.log("EXERCISE 6");
console.log(lastName);
console.log();
}
/**
Exercise 7
Using Array Destructuring get all of the names from this Nested Array
Hint:
https://untangled.io/in-depth-es6-destructuring-with-assembled-avengers
*/
{
console.log("EXERCISE 7");
const moreStudents = [
'Chris',
['Ahmad', 'Antigoni'],
['Toby', 'Sam']
];
Exercise 8
const props = [
{ id: 1, name: "Raj" },
{ id: 2, name: "Richa" },
{ id: 3, name: "Radha" },
];
Exercise 9: Solve the following
1) Write a function that can take in any number of arguments, and returns the sum
of all of the arguments.
2) Write a function called addOnlyNums that can take in any number of arguments
(including numbers or strings), and returns the sum of only the numbers.
3) Write a function called combineTwoArrays that takes in two arrays as arguments,
and returns a single array that combines both (using the spread operator).
4) Write a function called sumEveryOther that takes in any amount of arguments,
and returns the sum of every other argument.
5) Write a function called onlyUniques that can take in any number of arguments,
and returns an array of only the unique arguments.
6) Write a function called combineAllArrays that takes in any number of arrays as
arguments and combines all of them into one array.
7) Write a function called squareAndSum that takes in any number of arguments,
squares them, then sums all of the squares.
Exercise 10
Read the following data carefully and solve the problems stated below