Template literals country card problem Help | Sololearn: Learn to code for FREE!

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);

4/22/2021 5:28:39 PM

Lee 4 Code

2 Answers

New Answer

+3

"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();

+1

You sparked the right recollection! Thank you Rohit!