Description
- Inside lab3.js, you will export a class named lab3. In this class you will implement the following functions:
- testDefaultParamtersThe function takes two parameters, and the second parameter is defaulted to 100
- The function returns a json object containing two attributes: ‘first’ and ‘second’The ‘first’ attribute of the return object is defined as the first parameter of the function
- The ‘second’ attribute of the return object is defined as the second parameter of the function
- testTemplateLiteralsThe function takes three parameters, a firstName, middleName, and lastName
- The function returns a string with the three parameters separated by commasThe parameters should be concatenated using ES6 string templates, not ES5 string addition!
- testMultilineStringsThe function takes no parameters
- The function returns a multi-line string that is at least 4 lines longThe content of the string is up to you!
- testSortWithArrowFunctionThe function takes an array of numbers as a parameter
- The function returns the array sorted with a custom comparator that sorts the numbers descending
- Use the .sort function of the array and pass in a custom comparatorThe comparator should be implemented as an arrow function using ES6 syntax
class lab3{
function testDefaultParamters(a,b=100){
return json={
'first':a
'second':b
};
}
function testTemplateLiterals(firstName,middleName,lastName){
return myName='${firstName},${middleName},${lastName}';
}
function testMultilineStrings{
return
mySpell= `Uh-bare-toe.
AK-ee-oh.
AH-gwah-MEN-tee.
A-LAR-tey.`;
}
function testSortWithArrowFunction(a){
return a.sort((m,n)=>n-m);
}
}
export {lab3}