0

Template literals country card problem Help

The result is returned with the expected output, but also includes undefined function main() { var country = readLine(); var capital = readLine(); console.log(countryCard(country, capital)); } function countryCard(country, capital){ //complete the function //use backtick (` `) for template literal let msg = `Name: ${country}, Capital: ${capital}`; console.log(msg);

22nd Apr 2021, 5:28 PM
S C Lee
S C Lee - avatar
4 Answers
+ 1
//complete the code function main() { var country = readLine(); var capital = readLine(); countryCard(country, capital); } function countryCard(country, capital){ //complete the function //use backtick (` `) for template literal let msg = `Country: ${country}, Capital: ${capital}`; console.log(msg); }
7th Jan 2023, 12:32 PM
zrar
0
"undefined" is printed because of this line - console.log(countryCard(country, capital)); Because you are returning nothing from the countryCard but instead only printing S C Lee [CODE] function main() { var country = prompt(); var capital = prompt(); countryCard(country, capital); } function countryCard(country, capital){ //complete the function //use backtick (` `) for template literal let msg = `Name: ${country}, Capital: ${capital}`; console.log(msg); } window.onload = main();
22nd Apr 2021, 5:37 PM
Rohit
Rohit - avatar
0
You sparked the right recollection! Thank you Rohit!
22nd Apr 2021, 5:47 PM
S C Lee
S C Lee - avatar
0
Thank you, zrar !
17th Apr 2023, 3:01 PM
Leila