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

80
Views
processing of decimal numbers fails

I am trying to compare the numbers with another number and then classify it into a climate zone, but the following problem arises

I get data via a JSON file in that there are also decimal numbers with a decimal point, so these should be easily processed by my JavaScript code but if I try to use this, either undefined or NaN comes up, even if I just try to log the number can someone help me?

The JSON File:

{
  "tabel": [
    {
      "january": {
        "temperature": 6.9,
        "precipitation": 76
      },
      "February": {
        "temperature": 7.7,
        "precipitation": 88
      },
      "March": {
        "temperature": 10.8,
        "precipitation": 77
      },
      "april": {
        "temperature": 13.9,
        "precipitation": 72
      },
      "May": {
        "temperature": 18.1,
        "precipitation": 63
      },
      "June": {
        "temperature": 22.1,
        "precipitation": 48
      },
      "July": {
        "temperature": 24.7,
        "precipitation": 14
      },
      "August": {
        "temperature": 24.5,
        "precipitation": 22
      },
      "september": {
        "temperature": 21.1,
        "precipitation": 70
      },
      "October": {
        "temperature": 16.4,
        "precipitation": 128
      },
      "November": {
        "temperature": 11.7,
        "precipitation": 116
      },
      "December": {
        "temperature": 8.5,
        "precipitation": 106
      },
      "annual_average": {
        "tempertur": 15.5,
        "precipitation": 880
      }
    }
  ]
}

My Code:


const data = require("./data.json");
let k2;
let k3;
let humid = 0;

let k1;
if (data.tabel[0].annual_average.precipitation < 250) {
  k1 = "B";
} else if (data.tabel[0].annual_average.temperature > 15) {
  k1 = "A";
} else if (data.tabel[0].annual_average.temperature > 12) {
  k1 = "C";
} else if (data.tabel[0].annual_average.temperature > 0) {
  k1 = "D";
} else if (data.tabel[0].annual_average.temperature > -10) {
  k1 = "E";
} else if (data.tabel[0].annual_average.temperature < -10) {
  k1 = "F";
}
console.log(k1);

The Code Output: undefined

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

0

You have a typo in the field name

"annual_average": {
        "tempertur": 15.5,
        "precipitation": 880
      }

"temperatur" instead of "temperature"

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!