Problem
We are required to write a JavaScript function that takes in two strings. The first string specifies the user name and second the owner name.
If the user and owner are the same our function should return ‘hello master’, otherwise our function should return ‘hello’ appended with the name of that user.
Example
Following is the code −
const name = 'arnav'; const owner = 'vijay'; function greet (name, owner) { if (name === owner){ return 'Hello master'; } return `Hello ${name}`; }; console.log(greet(name, owner));
Output
Hello arnav