Am having issues importing my function getUserName to print on console:

import { getUserName } from "./helpers.js";

console.log('Hi ${getUserName(1)}, glad to see you');

it prints like this:

Hi ${getUserName(1)}, glad to see you , please help am stuck

    ali Change single quotes to backticks.

    console.log(`Hi ${getUserName(1)}, glad to see you`);

    Thanks, I would like to know is the best way to log a function variable to the console.

      ali console.log is the only thing you need to log something to the console in JS. There isn't anything better than this.

      Write a Reply...