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

186
Views
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 answers
Answer question

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 Report

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 Report

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 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!