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

111
Views
How would i make a function that will take user input and match it to a array and output the one that matches
function getItemFromSafe(password) {
    const itemsMap = {
      '10-A-w-4-878': 'Magic Wand',
      '16-R-a-9-1497': 'The one ring to rule them all',
      '5-N-3-441': 'Corgi',
      '9-Y-d-2-643': 'Apples and Pears',
      '7-H-673': 'Oscar nomination',
      '12-D-l-4-860': 'Chocolate Brownie'
    }
    return new Promise((resolve, reject) => {
      if (itemsMap[password]) {
        resolve(itemsMap[password])
      } else {
        reject('Unauthorised access to safe')    
      }
    })
  }

Then a function i want to write is

async function unlockSafe(customerName) {
  /** 
   * WRITE YOUR CODE IN HERE 
   **/
};

so i want to write a function that will generate the correct password based on the customers name who is trying to access the safe.

Like if you entered Magic Wand the password for that will come out and if there are any errors to display and error

about 4 years ago · Juan Pablo Isaza
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!