+ 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

12th Feb 2022, 10:09 PM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
7 Respostas
+ 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}`; }
12th Feb 2022, 11:15 PM
Anoir B'f
Anoir B'f - avatar
+ 4
Cause you're printing to the console two times one in the function and one in the main function
12th Feb 2022, 11:16 PM
Anoir B'f
Anoir B'f - avatar
+ 2
I even tried adding a space after “France,” but it still says Undefined.
12th Feb 2022, 10:14 PM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
+ 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!
28th Aug 2022, 8:01 AM
Yuliia Davydenko
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. 😁
13th Feb 2022, 12:44 AM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
0
Ywlcm bro👍
13th Feb 2022, 2:34 AM
Anoir B'f
Anoir B'f - avatar
0
this doesn't, even the answer provided by the app, really frustrating 😑
15th Jan 2023, 7:33 PM
AndrewOmodo
AndrewOmodo - avatar