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

256
Views
Write function, which returns an unique identifier for parameter.(Java Script)

I have tried to do it, but all I get is that output: ---> Symbol(Test) Is it even possible to get output like this(with single quotes in it): ---> Symbol('Test')

function getUnique(param) {
    param = Symbol(param);
    return param;
} 

console.log(getUnique('Test')) // Symbol('Test') <--- I need to get that output 

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

[Updated] Not sure if this is what you want...

function getUnique(param) {
    param = Symbol("'" + param + "'");
    return param;
} 

console.log(getUnique('Test')) 

about 4 years ago · Juan Pablo Isaza Report

0

I may be completely misunderstanding your question, but if you mean

Symbol('Test') <--- I need to get that output

You can append the single quote characters to the string like so:

const getUnique = (param) => {
  const sym = Symbol(param);
  return sym;
}

console.log(getUnique(`'test'`))

about 4 years ago · Juan Pablo Isaza Report

0

The representation of what gets printed at the console is implementation dependent and could even vary from version to version of the same implementation. Running it in latest chrome gives an output of Symbol(Test) and firefox gives Symbol("Test"). It's the same thing either way: the console printed output is just a representation of the thing. It isn't actually any different, it's still a unique Symbol 'Test'.

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!