3. Short-Term Memory - return true;


#1


https://www.codecademy.com/courses/close-the-super-makert/0/3?curriculum_id=506324b3a7dffd00020bf661#


i want to ask why the "return true" is necessary in the scan function.


scan: function (item) {
        switch (item) { 
        case "eggs": 
            this.add(0.98); 
            break;
        
        case "milk": 
            this.add(1.23); 
            break;
        
        //Add other 2 items here
        case "magazine": 
            this.add(4.99); 
            break;
        
        case "chocolate": 
            this.add(0.45); 
            break;   
        
        }
        return true; // why is this code necessary here?


#2

What makes you say that it's required?
Be careful with how you treat assumptions, treating them as unconditional facts will lead you to questions and conclusions that don't make sense or don't add up.


#3

sorry, i do not get what you mean.

the "return true;" code is given in the exercise.( i didn't create that line of code) So i am asking why that line of code is necessary or,

in other words, what is the rationale behind in writing this line of code which is in the scan function.


#4

Was there by default, I see.
Still can't start with the assumption that it's required though!
So the question then is whether it's used for anything.
Doesn't appear that way. All calls to it ignore what it returns.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.