Multiple choice technology web technology

How do you create a function?

  1. function:myFunction()

  2. function myFunction()

  3. function=myFunction()

  4. function=myFunction(){ }

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

JavaScript functions are declared using the 'function' keyword followed by the function name and parentheses, with the function body enclosed in curly braces. Option B shows the correct syntax. Options A, C, and D use incorrect separators (: or =) instead of a space, which are not valid JavaScript function declaration syntax.