1

So I'm part of a bootcamp that helps you get job ready to do web development. I hit a snag and wanted to know if anyone could shed some light. inTruth('I', 'is', 'dumb'); The goal is to have the Bootstrap class's method "registerStudent", verify if there is a matching object within it's array "students" if there is, it say "there is already a student registered", if not it will add the called method and add the object to the class's array. If my explanation isn't through. runApology('I', 'am', 'sorry', * 2);

HTML

<head>
    <title>Nucamp Community Coding Bootcamp</title>
</head>
<body>
    <h1>Nucamp Community Coding Bootcamp</h1>
    <script src="ReactWeek1Assignment.js"></script>
</body>
</html>

class Student {
    constructor(name, email, community) {
        this.name = name;
        this.email = email;
        this.community = community;
    }
}
class Bootcamp {
    constructor(name, level, students = []) {
        this.name = name;
        this.level = level;
        this.students = students;
    }
        registerStudent(studentToRegister) {
                if (this.students.filter(s => s === studentToRegister)){
                    this.students.push(studentToRegister);
                    console.log(`Registering ${studentToRegister.name} to ${this.name} with email ${studentToRegister.email}`);
                    return this.students;
                } else {
                    console.error(`${studentToRegister.name} is not registered`);
                    return this.students;
                }
            }

        }

1 Answer 1

1

I would suggest to use Lodash. It has many in-built comparison functions. You should use the isEqual() for the same. Kindly refer the following code.

_.isEqual(obj1,obj2);

For further reference you can refer this documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.