Home > Software engineering >  How do I make this happen when I do a function and put the parameters?
How do I make this happen when I do a function and put the parameters?

Time:11-15

function[function name](parameters){
  console.log(string attached to parameter, string attached to parameter, parameter) and print)
}

Now what I have is this:

What I have

Perform the task I want to do in the function.

CodePudding user response:

First, you have a semicolon which doesn't have to be there, second, string interpolations follow the format ${variableName}, not {variableName}$, so you need to change your function to :

function fcuadratica (a, b, c) {
  console.log(`x² ${a}, ${b} x`)
}

CodePudding user response:

I do not understand exactly what you are trying to achieve but this shows one way of formatting a template string to make it look like a quadratic equation.

function fcuadratica (a, b, c) {
  console.log(`${a}x²   ${b}x   ${c} = 0`)
}

fcuadratica(3, 4, 2);

  • Related