+ 2

Could anyone help me out with this one please? Thank you in advance!

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 //My 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 var newVar = `Name: ${country}, Capital: ${capital}`; console.log(newVar); }

25th Jul 2021, 7:46 PM
Sanchit Bahl
Sanchit Bahl - avatar
19 Respuestas
+ 10
let country = readLine(); let capital = readLine(); let countryCard = `Country: ${country}, Capital: ${capital}`; //complete the code console.log(countryCard);
14th Apr 2023, 12:37 PM
Pavi
Pavi - avatar
+ 3
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 var display =`Name: ${country}, Capital: ${capital}`; return display; } Good Luck
25th Jan 2022, 8:40 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
+ 3
I'm tired of this question I try all your answer but it couldn't work please help me
11th Dec 2022, 2:24 PM
kidist yama
kidist yama - avatar
+ 2
return newVar;
25th Jul 2021, 9:14 PM
Sanchit Bahl
Sanchit Bahl - avatar
+ 1
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 var display =`Name: ${country}, Capital: ${capital}`; return display; } It's working for me
10th Aug 2021, 5:09 AM
Nandhini Subramanian
Nandhini Subramanian - avatar
+ 1
let country = readLine(); let capital = readLine(); //complete the code console.log(`Country: ${country}, Capital: ${capital}`); Ensure there are no spaces between the characters in this code segment.
19th Jun 2024, 6:20 PM
sneha gondaliya
sneha gondaliya - avatar
0
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 return `Name: ${country}, Capital: ${capital}`;
26th Mar 2022, 9:39 PM
Amit Pathak
Amit Pathak - avatar
0
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 return `Name: ${country}, Capital: ${capital}`; } Make sure you have single spaces between the variables and text. also you cant use console.log since it has been used while calling the function just return the result directly or assign to a variable then return all the same... thanks
8th Aug 2022, 1:44 AM
SureCoder
SureCoder - avatar
0
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:02 AM
Yuliia Davydenko
0
it return undefined because of this line console.log(countryCard(country, capital)); try to remove console.log
5th Sep 2022, 5:09 AM
Noel Mgongo
Noel Mgongo - avatar
0
I did it in 3 ways 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 return `Name: ${country}, Capital: ${capital}`; } ///// function main() { var country = readLine(); var capital = readLine(); let x = countryCard(country, capital); console.log(x); } function countryCard(country, capital){ //complete the function //use backtick (` `) for template literal var x = `Name: ${country}, Capital: ${capital}`; return x; } //////// 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 var x = `Name: ${country}, Capital: ${capital}`; return x; }
15th Sep 2022, 10:39 PM
Andres Moran Cabello
Andres Moran Cabello - avatar
0
I also tried each and every solution, but nothing worked. Could you guys please help me?
15th Dec 2022, 6:07 PM
ROBEL GUDISSA
ROBEL GUDISSA - avatar
0
I have already tried everything and nothing works -_-
2nd Feb 2023, 7:37 PM
Marta S. Vinet
Marta S. Vinet - avatar
0
return`Name: ${country}, Capital: ${capital}`; use this.....
28th Feb 2023, 1:16 PM
Hifza Mehfooz Ahmed
0
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 var display =`Country: ${country}, Capital: ${capital}`; return display; }
3rd Mar 2023, 2:01 PM
Halil Ibrahim Tasdemir
Halil Ibrahim Tasdemir - avatar
0
using System; class Program { static void Main() { string country = Console.ReadLine(); string capital = Console.ReadLine(); Console.WriteLine(countryCard(country, capital)); } static string countryCard(string country, string capital) { // Use string concatenation or the appropriate syntax for C# string interpolation return
quot;Country: {country}, Capital: {capital}"; } } Syntax errors in C# code: missing semicolons, curly braces, and identifiers; invalid use of backticks (`) and dollar signs ($) in string interpolation; namespace cannot directly contain members such as fields or methods. Try this method.
18th Jan 2024, 9:58 AM
Francois Waldeck
Francois Waldeck - avatar
0
Hello Friends.what is the of this code:? I mean the problem let country = readLine(); let capital = readLine(); let countryCard = `Country: ${country}, Capital: ${capital}`; //complete the code console.log(countryCard)
28th Aug 2024, 3:36 AM
Hector Mercedes De Los Santos Feliz
Hector Mercedes De Los Santos Feliz - avatar
- 2
8th Aug 2021, 6:29 PM
Abou Thiongane
Abou Thiongane - avatar