[Solved] Stuck with the talk method creation (in french version)


#1

https://www.codecademy.com/fr/courses/javascript-beginner-fr-FR-y2vdo/0/3

Oups, merci de réessayer. On dirait que votre méthode parle ne prend pas correctement un argument pour afficher la bonne chaîne de caractères.


var jules = {
    job: "developpeur",
    fiance: false,
    parle: function(humeur){
        if(humeur === "super"){
            console.log("Salut, je me sens très bien");
        }else if(humeur === "pas mal"){
            console.log("Salut, je ne me sens pas trop mal");
        }else{
            console.log("Erreur on " + humeur);
        }
    }
};

jules.parle("super");
jules.parle("pas mal");

I try with the switch(){} controller too, none works fine.


#2

@arnome,

The code-checker uses following check

var test_function = function(){
  var loggedFromSpeak = [];
  var holderfunction = console.log;
  console.log = function(x) {
      loggedFromSpeak.push(x);
      };
  if (jules.parle("super") !== undefined) {
     console.log = holderfunction;
     return "La m\u00e9thode parle() devrait afficher"+
            " quelque chose dans l'\u00e9diteur et ne rien retourner !";
  }
  jules.parle("pas mal");
  if (loggedFromSpeak[0] !== "Salut, je me sens tr\u00e8s bien" ||
      loggedFromSpeak[1] !== "Salut, je me sens pas trop mal") {
        console.log = holderfunction;
        //return loggedFromSpeak;
        return "On dirait que votre m\u00e9thode parle ne prend pas "+
               "correctement un argument pour afficher la bonne "+
               "cha\u00eene de caract\u00e8res.";
  }
};
test_function();

I do not have a solution for your problem......


#3

No else if expected. Just write an else...

        else {
            console.log("Salut, je ne me sens pas trop mal");
        }

#4

I 've already try that but it does not working either. The weird thing is that the console log print the correct answer whereas the control I use (switch, just one if, if and else if). I check the code-checker function (thank's leonhard.wettengmx.n) and my little script should pass this test because it just check the output of the consol and my output is correct. I really don't know where the error is.

arnome.


#5

Ok , I found the bug:
The two sentences expected from the exercice are:
"Salut, je me sens très bien"
and
"Salut, **je ne me** sens pas trop mal"
and the two sentences expected by the code-cheker from the console.log are:
"Salut, je me sens très bien"
and
"Salut, **je me** sens pas trop mal"
There miss " ne " in the code-cheker.
So if we copy-paste sentences from the exercice, the second sentence lead to an error.
thank's to mtf and leonhard.wettengmx.n,

arnome.


#6

#7

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