You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 1. Write a function that takes two input `firstName` and `lastName` and returns full name. You will get the full name by adding first and last name with an space.
// 2. After writing the function write two tests for above function
// 3. Make first test fail to see the result of the second test
functionfullName(firstName="",lastName=""){
returnfirstName+" "+lastName;
};
letresult=fullName("Arya");
letexpected="Arya Stark";
letresult=fullName("John","Snow");
letexpected="John Snow";
if(result!==expected){
thrownewError(`${result} is not equal to ${expected}`)
}
// Calculate total amount
// 1. Write a function that takes two input `amount` and `taxRate` and returns the total amount by `amount + (amount * taxRate) `
// 2. Write two tests for the above function
// 3. Make the first test fail to see the result for the second
functiontotalAmount(amount,taxRate){
returnamount+(amount*taxRate)
}
letresult=totalAmount(25,5);
letexpected=50;
letresult=totalAmount(30,3);
letexpected=120;
if(result!==expected){
thrownewError(`${result} is not equal to ${expected}`)