Assignment #2 autograding errors

I am not able to clear following two agutograde errors. If anyone knows the solution, please let me know.

  1. Scrabble Scorer solution newPointStructure contains the correct key-value pairs
    Message:
    Expected $.a = undefined to equal 1.
    Expected $.e = undefined to equal 1.
    Expected $.i = undefined to equal 1.


    Stack:
    Error: Expected $.a = undefined to equal 1.
    Expected $.e = undefined to equal 1.
    Expected $.i = undefined to equal 1.
    Expected $.o = undefined to equal 1.

  2. Scrabble Scorer solution transform returns an object
    Message:
    Expected instance of Boolean to be an instance of Object

Hey there,

From the first set of error messages, where the test is expecting key-value pairings of a = 1, e = 1, i = 1, etc, it looks like the key-value pairs coming from your function are ‘undefined’. There could be a number of reasons for this, but error message 2 has a big hint.

Take a look at the expected verses actual value for the transform function in message 2. It is expecting the function to return an object, but instead got a Boolean. If you revisit your transform function, the problem likely lies there.

Thank you, i am able to clear one error. still error on the follwing

function transform(oldPointStructure) {
let newStructure = {};

for (let item in oldPointStructure){
let letters = oldPointStructure[item];

for (let i = 0; i < letters.length; i++) {
    newStructure[letters[i].toLowerCase()] = Number(item);
}

}
console.log(newStructure);
return newStructure;
};

Failures:

  1. Scrabble Scorer solution newPointStructure contains the correct key-value pairs
    Message:
    Expected $.a = undefined to equal 1.
    Expected $.e = undefined to equal 1.
    Expected $.i = undefined to equal 1.


    Stack:
    Error: Expected $.a = undefined to equal 1.
    Expected $.e = undefined to equal 1.
    Expected $.i = undefined to equal 1.
    Expected $.o = undefined to equal 1.

printed object before return in transform

tried follwing both, still same autograding error

{
a: 1,
e: 1,
i: 1,
o: 1,
u: 1,
l: 1,

{
a: 1,
b: 3,
c: 3,
d: 2,

Hey @ramsundary,

Since your transform function looks good, and seems to output the right key-value pairs via your console.log statement, the same reference error with undefined properties is odd.

The failure message notes that newPointStructure is meant to contain these key-value pairs, so it looks like Jasmine is testing an object called ‘newPointStructure’ instead of just testing your function, which looks to be working. Within your scrable-scorer.js file, are you assigning the transformed old structure to a variable called newPointStructure?

Hi @jwrounds,

Yes, transformed old structure assigned to newPointStructure. Function transform returns newPointStructure. 

fun transform(oldPointStructure) {

for (let item in oldPointStructure){
let letters = oldPointStructure[item];

for (let i = 0; i < letters.length; i++) {
    newPointStructure[letters[i].toLowerCase()] = Number(item);
}

}

let pointStructure = {};
let keys = [], k, i;

for (k in newPointStructure) {
if (newPointStructure.hasOwnProperty(k)) {
keys.push(k);
}
}

keys.sort();

for (i = 0; i < keys.length; i++) {
k = keys[i];
pointStructure[k] = Number(newPointStructure[k]);
}

newPointStructure = pointStructure;
//console.log(newPointStructure);

return newPointStructure;
};