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

188
Vistas
Javascript function parameter query

Do javaScript accept multiple strings as a function parameter?

function name(Haydon Lyson){
//code
} 

will it be accepted? If not then how can we pass multiple strings as function parameter.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can use the rest parameter for that rest parament

function name(...params){
  // ...params return an array of parameters
  // like this [hadon ,dsjfl,sdfl];


}
       or


function name(name1,name2,name3,name4){
// you can use multiple params if you know params exact length
// if you don't length of params then 
// use above methods
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can just pass them in separating them by comma:

function name(haydon, lyson) {
   console.log(haydon, layson)
}
let haydon = 1
let lyson = 5

name(hayden, lyson)
about 4 years ago · Juan Pablo Isaza Denunciar

0

Passing multiple strings as a function parameter can be done one of two ways.

The first is by taking in the strings as parameters and separating them by commas.

var haydon = "Haydon";
var lyson = "Lyson";

function name(haydon, lyson){
//code
} 

The second way is to pass in an object into your function so that you can have the ability to manipulate the key-value pairs into strings in your function, allowing for a massive amount of inputs with just one single parameter.

let names = {
    cersei: 'Lannister',
    arya: 'Stark',
    jon: 'Snow',
    brienne: 'Tarth',
    daenerys: 'Targaryen',
    theon: 'Greyjoy',
    jorah: 'Mormont',
    margaery: 'Tyrell',
    sandor: 'Clegane',
    samwell: 'Tarly',
    ramsay: 'Bolton',
    haydon: 'Lyson'
}

function name(names){
//code
} 

Hope this helps!

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