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

83
Views
case switch and scope in js

I'm looking for some help. I am not sure my speed, handling, acceleration values in the bottom method arguments are not being affected or using the update values that are being added to within the case-switch. I want speed to take the changes applied in the switch then the updated variable to be pushed in the methods below. I hope I'm making sense. My values always stay at 10

const addAttributes = (_element) => {let selectedElement = _element.layer;

    var speed = 10;
    var handling = 10;
    var acceleration = 10;
  
    switch (_element.layer.name) {
 
      case "1_grill":
        speed = speed + 100;
      
      case "Fiber1":
        handling = handling + 25;
        speed = speed + 25;

      case "yellow_headlights": // asset name without #
        acceleration = acceleration + 35;
    }
   
    attributesList.push({
        trait_type: "Handling",
        Value: handling,})

    attributesList.push({
        trait_type: "Speed",
        Value: speed,})
  
    attributesList.push({
        trait_type: "Acceleration",
        Value: acceleration,})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Maybe it's because you'e _element.layer.name doesn't match any of the cases never. You should check that.

And you should put a break after each case too.

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!