CodeNewbie Community 🌱

rfsimoes2
rfsimoes2

Posted on

What is wrong with my JavaScript code?

Hi all,

I'm in a middle of a Javascript course that it's part of a bootcamp candidature.

The exercice is the following:

Help Elliott and the fSociety crew with a little pet project. Security is paramount to this group of anarchist rebels. And someone has to make sure that their hideout is not compromised.
The password to enter the Arcade has to be kept secure, and it changes every day. The first seven characters change every week, while the last ones are updated every day. The daily password is generated by appending to the weekly password the consonants of the day of the week we are in.
Your job is to create a piece of software that automatically updates the password every time a day goes by and print it.
Instructions
Having got the value of the weekly password stored in weeklyPass, update and print to the console the value of currentPass depending on the day of the week we are in. To know which day of the week it is simply access weekDay.
Remember that updating the password is appending the letters corresponding to the consonants present in the name of the current day of the week.
There are many ways of cracking this problem, but Elliot and the guys specifically asked for you to use a switch statement...

The code I generated is the following:

var weeklyPass = ‘darlene’; 
var weekDay = ‘friday; 
var currentPass; 

// 'y' is a vowel in this case 
// https: //ww.merrian-webster.com/words-at-play/why-y-is-sometimes-a-vowel-usage 

switch(weekDay){ 
    case “friday”: currentPass = weeklyPass + "frd"; 
    break; 
    case "saturday": currentPass = weeklyPass + “strd"; 
    break; 
    case "sunday": currentPass = weeklyPass + "snd"; 
    break; 
    case "monday": currentPass = weeklyPass + "mnd"; 
    break; 
    case "tuesday": currentPass = weeklyPass + “tsd"; 
    break; 
    case "wednesday": currentPass = weeklyPass + "wdnsd"; 
    break; 
    case “thursday”: currentPass = weeklyPass + “"thrsd"; 
    break; 
    default: console.log("Wrong weekday!"); 
} 
console.log("Today\'s password is: “ + currentPass);
Enter fullscreen mode Exit fullscreen mode

And the output is:

Code is incorrect
Your code is producing the wrong output. The password stored in currentPass is incorrect! Be sure your code works for all possible outcomes.



console.log output is:
Today's password is: darlenefrd

Can anyone help please, as I'm stuck here and can't figure out what am I doing wrong.

Best Regards
Ricardo Simoes

Top comments (0)