Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

86
Visualizações
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,})
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda