function cname(name){
const username = `${name}`;
return username;
}
fname = prompt(`Enter your first name ${name}`)
lname = prompt(`Enter your last name ${name}`)
console.log(`Hello ${fname} ${lname}`);
----------------------------------------------
// Say hello to the user
const sayHello = (firstName, lastName) => `Hello, ${firstName} ${lastName}!`;
// Alternative solution using a function declaration
/* function sayHello(firstName, lastName) {
return `Hello, ${firstName} ${lastName}!`;
} */
const firstName = prompt("Enter your first name:");
const lastName = prompt("Enter your last name:");
console.log(sayHello(firstName, lastName));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter