I’m doing a lab exercise on VScode for an assignment and I’m unable to pass one of the Mocha test requirements. This test requires “takes in two arguments, a name and a language, and language defaults to JavaScript”. I’ve tried to default it to “Javascript” value assuming it wants a switch statement. This is the following requirements:
describe('introductionWithLanguageOptional(name, language)', function() {
it('takes in two arguments, a name and a language, and language defaults to JavaScript', function() {
expect(introductionWithLanguageOptional("Gracie")).toEqual("Hi, my name is Gracie and I am learning to program in JavaScript.");
})
})
Quite frankly, I’ve confused myself.
This is what I’ve tried:
function introductionWithLanguageOptional(name, language= "Javascript"){
switch (name, language) {
case(name, language) :
return `Hi, my name is ${name} and I am learning to program in ${language}.`
break;
default:
return `Hi, my name is ${name} and I am learning to program in ${language}.`
}
}
console.log(introductionWithLanguageOptional("Gracie"))
//It returns with:
Hi, my name is Gracie and I am learning to program in undefined.