+ 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); }
19 Answers
+ 10
let country = readLine();
let capital = readLine();
let countryCard = `Country: ${country}, Capital: ${capital}`;
//complete the code
console.log(countryCard);
+ 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
+ 3
I'm tired of this question I try all your answer but it couldn't work please help me
+ 2
return newVar;
+ 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
+ 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.
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}`;
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
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!
0
it return undefined because of this line
console.log(countryCard(country, capital));
try to remove console.log
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;
}
0
I also tried each and every solution, but nothing worked. Could you guys please help me?
0
I have already tried everything and nothing works -_-
0
return`Name: ${country}, Capital: ${capital}`;
use this.....
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;
}
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.
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)
- 2