+ 4
ES6 Variables and Strings
You need to make country cards for a school project. The given program takes the country and its capital name as input. Complete the function to return a string in the format you are given in the sample output: Sample Input Portugal Lisbon Sample Output Name: Portugal, Capital: Lisbon Use template literals to output variables in strings. //My output looks correct but says it's undefined? https://code.sololearn.com/WxpXmW1mig43/?ref=app
7 Answers
+ 13
Try to return the value that you've got:
function main() {
var country = readLine();
var capital = readLine();
console.log(countryCard(country, capital));
}
function countryCard(country, capital){
return`Name: ${country}, Capital: ${capital}`;
}
+ 4
Cause you're printing to the console two times one in the function and one in the main function
+ 2
I even tried adding a space after āFrance,ā but it still says Undefined.
+ 1
Just came here to say, guys check the comma))
I also thought it's the platform bug, but the platform is ok, it turned out I missed a comma after {country} lol. Hope it helps!
0
Anoir B'f Thank you!!! It worked to use keyword return instead of logging to the console. I also had to add a space before the second tick mark for it to pass all tests. š
0
Ywlcm broš
0
this doesn't, even the answer provided by the app, really frustrating š