Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

0

Your answer:

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

Please read Constructor vs. declaration vs. expression

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda