I'm a bit confused about the AssertionError [ERR_ASSERTION]: undefined == 390 in Gitlab.
What I need is:
The sumSalaries(obj) function, which should take an object obj as a parameter where the field names correspond to the employee's name and the values represent each employee's salary.
Consider the following code snippet:
export default function sumSalaries(obj) {
let salaries = {
John: 100,
Jane: 160,
Mike: 130
};
let sum = 0;
for (let key in salaries) {
if (salaries.hasOwnProperty(key)) {
sum += salaries[key];
}
}
obj = sum;
console.log(obj);
}
sumSalaries();
The test should:
import sumSalaries from "../test.js";
import assert from "assert";
describe("\n\ntest.js", () => {
it("should return the correct sum", () => {
[
[
{
John: 100,
Ann: 160,
Pete: 130,
},
390,
],
[
{
John: 80,
Jane: 160,
Mike: 190,
},
430,
],
[
{
Charlie: 84,
Victor: 160,
Pete: 200,
},
444,
],
].map((obj) => {
let salaries = obj[0];
let sum = obj[1];
assert.equal(sumSalaries(salaries), sum);
});
});
});
The error message I received from Gitlab is:
AssertionError [ERR_ASSERTION]: undefined == 390