0
Please what's wrong with this code
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 = `${country}, Capital: ${capital}`; console.log(msg); } It's supposed to take country and capital as input and output it in a particular format. E.g France Paris Output France, Capital: Paris But what I'm getting is France, Capital: Paris Undefined
4 ответов
+ 3
Davies Olaniyi you are using console.log two times on the same output . When the function is called it logs the output itself .
But when you use console.log again on function call it returns undefined since function returned nothing .
So either return the msg from the function and then use console.log on function call or simply call the function with no console.log
+ 3
I don't know what it asks to do but i guess it is missing string Country in msg.
+ 1
Abhay Thanks a bunch. I called it with return and it worked
0
It's supposed to take country and capital as input and output it in a particular format.
E.g France
Paris
Output
France, Capital: Paris
But what I'm getting is
France, Capital: Paris
Undefined