Creating a function to display a greeting message

Report a typo

Your task is to create a simple multi-line JavaScript program using the basic concepts. The requirement is to define a variable named greeting that contains a string 'Hello, User!', create a function named displayGreeting which, when called, prints the greeting. Can you fill the blanks in code to make it happen?

Fill in the gaps with the relevant elements
// Define a variable and assign a string value
 greeting = "Hello, User!";

// Define a  to display the greeting
function displayGreeting() {
  (greeting);
}

// Call the function
displayGreeting();
functionletconsole.log
___

Create a free account to access the full topic