• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

122
Vistas
I am adding javascript 0.1 but it is adding missing

I am aiming to find all combinations of a 4 digit number among the given values. But even though I set .1 increment in json it is increasing .09999999. This increment error occurs after step 2. No way could I solve it. Can anyone see where I am wrong in the code below? Have something to add?

window.onload = ()=>{

    class playSearch {




        createCombination(arr) {
    /*
    ppp => i
    atr-f => f
    atr-p => p
    
    */
            this.combination = [];
    
            for (let i = arr[0].min; i <= arr[0].max; i = i + arr[0].plus) {
            
                for (let f = arr[1].min; f <= arr[1].max; f = (f + arr[1].plus)) {
                  console.log(arr[1].plus)
                  console.log(f)
                    for (let p = arr[2].min; p <= arr[2].max; p=p+arr[2].plus) {
                      
                        for (let m = arr[3].min; m <= arr[3].max; m=m+arr[3].plus) {
                         
                            this.combination.push([i,f,p,m])
                           
                        }
                        
                    }
    
                }
                
            }
    
         
    
    
    
    
    
    
        }
    
    }
    
    
    var user = new playSearch();
    user.createCombination(
        [
            {
                "name": "ppp",
                "min": 1,
                "max": 11,
                "plus": 1
            },
    
            {
                "name": "atr-f",
                "min":10,
                "max":20,
                "plus":1/10
            },
            {
                "name":"atr-p",
                "min":1,
                "max":5,
                "plus":1
            },
            {
                "name":"min-profit",
                "min":1,
                "max":5,
                "plus":1
            }
        ]
    )
}

I couldn't understand why .0999 was added even though I added .1. The plus in the json determines the amount of increase. I'm waiting for your help. enter image description here

over 3 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda