Autograder Assignment 2

So I went through the autograder, didn’t change the names of anything, and it still failed. Can someone point me in the right direction as to what I have different than what the autograder wants?

:flushed: removed code shot - try describing your solution instead :flushed:

In the error after the “to contain” portion of the error it will tell you what it expects. It is picky but its expecting your key for the scoring fuction within the scoringAlgorithms object to be named something other than scorerFunction:

1 Like

I just chgd to scoringFunction key from scorerFunction and my code was working in Repl.it.
Then GitHub - still getting Autograder 11 failures (numerous tries): For: simpleScore, scrabbleScore, vowelBonusScorer Type Errors: they are not functions and Errors: Expected ‘object’ to be ‘function’.
with only one Autograder area 4) Scrabble Scorer solution scoringAlgorithms contain three scoring objects - which states: to contain <jasmine.objectContaining(Object({ scoringFunction: Object({ name: ‘Scrabble’, description: ‘The traditional scoring algorithm.’, scoringFunction: Function }) }))>. I have fooled around with below code all afternoon trying to figure out what this means? with no success. At one point I even tried additional key named scoring function: to hold what I previously thought was my complete object and this did not work either (at least the way I tried it).
I set-up each object like:
let simpleScore = {
name: “Simple Score”,
description: “Each letter is worth 1 point.”,
scoringFunction: function simpleScorer(word) {
let simpleScore = 0; Note: same as Object (or function) name in my code
for(let i=0; i<word.length; i++) {
simpleScore ++;
}
return simpleScore; Note: same as Object (or function) name in my code
}
};
then put all objects in array:
const scoringAlgorithms = [simpleScore,vowelBonusScore,scrabbleScore];
I looked up the JS Type Error ‘x’ is not a function online. - occurs when there was attempt to call value from function but value is not actually a function. It states:

  1. maybe there is a typo in the function name? I believe my function names simpleScorer (see location above), vowelBonusScorer, and scrabbleScorer are correct. I do not know where to look to see if this is what Autograder expects. Where can I find proper function names if not correct?
  2. maybe the object you are calling this function on does not have this function? I believe my three objects have the above functions listed.
  3. Also looked to make sure that property names and function names were not the same.
    But I do have object (or function) name the same as the variable name I am using to calculate score and return but I believe I changed these to be different at one point in time and di not help errors so changed back.
    Please help.

Thank you. I was going with what the example in the instructions had. I didn’t realize that there was a “to Contain” part of the error message. I changed everything and it passed the autograder

@SprintsMcGee and @phoa - See my reply above - sorry long - Please confirm below and I believe then I will know how to change my code to pass autograder.
So the function names should be: simpleScore, vowelBonusScore, and scrabbleScore (v. simpleScorer, vowelBonusScorer, and scrabbleScorer per instructions?)
And original let simplescore; in code is not intended to be an object name declaration but the variable that holds the function like: let simpleScore = function(word) { //function body with return } - this was very confusing to me and I spent a lot of time trying to figure it out.

@Ebbie Correct. The function names should be what you stated instead of what the instructions said to pass the auto-grader. I don’t understand what you are asking in your 2nd question but you should create each function (simpleScore, vowlBonusScore, and scrabbleScore) outside of the 3 objects you are creating for each respective function. Then, within each object within the scoringFunction key you would call that respective function. Would be set up as

scoringFunction: (then you just call the function that corresponds with that object ex.) scrabbleScore,