Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
NaN output in Javascript from a class function

I need to solve the following problem:

Create class Intern with next fields: Name(String) Surname(String) laziness(number from 20 to 50) Curiosity (number from 0 to 100) Skill (number from 0 to 100) Irresponsibility (float number from 0.0 to 1.0) For this class create method that calculate “mark” for intern, that is calculated by formula(in the code) It looks simple, but when I run it, the output is NaN. Could somebody help please?

class Intern {
    constructor(name, surname, laziness, curiosity, skill, irresponsibility) {
        this.name = name
        this.surname = surname
        if (laziness <= 50 && laziness >= 20) {
            this.laziness = laziness
        } else {
            this.laziness = 0
        }

        if (curiosity <= 100 && curiosity >= 0) {
            this.curiosity = curiosity
        }
        if (skill <= 100 && skill >= 0) {
            this.skill = skill
        }
        if (irresponsibility <= 0 && irresponsibility >= 1) {
            this.irresponsibility = irresponsibility
        }
    }

    getMark() {
        let mark = (((this.skill + this.curiosity) * (1.5 - this.irresponsability)) / (this.laziness * 0.25));
        return mark
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You've misspelled the irresponsibility variable in the getMark() method, and the if statement in your constructor for it will never be true:

if (irresponsibility <=0 && irresponsibility >=1)

I think you were meaning to say:

if (irresponsibility >=0 && irresponsibility >=1)
about 4 years ago · Juan Pablo Isaza Denunciar
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda