0
Whats wrong with this code
I want to print Name and Capital its giving me an error whats wrong WHY! 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 const name `Name: ${country}, Capital: ${capital}`; }
9 ответов
0
Abdul Qadir
You have to do like this
console.log("Name: " + `${country}` + ", Capital: " + `${capital}`);
or like this
console.log(`Name: ${country}`+ ", " + `Capital: ${capital}`);
+ 3
Abdul Qadir
Both are working for me. I gave you solution after tried both. I think you are doing some mistakes.
+ 2
Instead of using console.log, you need to use return (`Name: ${country}`+","+` Capital: ${capital}`);
Since in the main you are already printing, you just need to return it
0
Thank you i tried that. it is printing the answer but it is still saying undefined in next line and test case still fail 🤷🏻♂️why
0
Nevermind i understand the logic. But tescases still failing thank you though. I tried both but not working
0
Yesh both are working but after that it is showing me undefined in next line.
0
ES6 Variables and Strings
0
That was my solution:
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
country= `Name: ${country}`;
capital = `Capital: ${capital}`;
return(country+", "+capital);
}