Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Function Expression (JavaScript)

Convert the function named functionDeclaration to an anonymous function expression and assign it to a variable called myFunc.

function functionDeclaration() {
  let myFunc = str
   return "Hi there!";

}

console.log(myFunc())

I'm new to coding. What am I doing wrong? It's supposed to print 'Hi there!' but keeps giving me a reference error message.

Thank you for your help!

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Your function expression could be like,

const func = function functionDeclaration() {
    return "Hi there!";
 }
 
 let myFunc = func()
 console.log(myFunc);
about 4 years ago · Juan Pablo Isaza Report

0

I am not sure what is the purpose of let myFunc = str, but give this a try -

function functionDeclaration() {
  // let myFunc = str
  return "Hi there!";
}

const myFunc = () => {
  return functionDeclaration.call(this);
}

console.log(myFunc());
about 4 years ago · Juan Pablo Isaza Report

0

Your answer:

let myFunc = function() {
    return "Hi there!";
}

Please read Constructor vs. declaration vs. expression

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!