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

169
Views
Cannot convert undefined or null to object at Function.entries (<anonymous>)

I'm trying to pull data from the console on one page, written in json and then transfer it to another using this script, but I'm having problems. Help solve the problem)

JS code

chosen = JSON.parse(sessionStorage.getItem('chosen'))
console.log(chosen)
let s = "";
let sum = 0.0;

for (let [key, value] of Object.entries(chosen)) {
    s += `<p>${key} (${value['value']}): \u20ac ${value['price']}</p>`
    sum += parseFloat(value['price'])
}
s += `<p>Total: ${sum}</p>`

document.getElementById("components").innerHTML += s;

Error

order.js:6 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at order.js:6
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Can you define your chosen variable correctly and try again?

This chosen = JSON.parse(sessionStorage.getItem('chosen')) should be like this => const chosen = JSON.parse(sessionStorage.getItem('chosen'))

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!