Jump to content

Switch Statement | Como construir uma password

Recommended Posts



Tenho o problema seguinte para resolver e o código que escrevi (2 opções abaixo), mas acabo por ter sempre o erro seguinte:

'>>>>Code is incorrect
Your code is not up to fSociety standards, keep trying to improve it'

O erro em si não é explícito, o que me dá a entender que há uma qualquer subtileza na syntaxe, que ainda que possa não estar errada, não corresponde.
Preciso de mais ideias para resolver este problema, pf.

"Having got the value of the weekly password stored in weeklyPass, update 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…"


var weeklyPass = 'darlene';
var weekDay = 'monday';
var weekDayApp = weekDay.replace(/[aeiouy]/gi,'');
var currentPass;

    switch (weekDay) {
        case 'monday':
        console.log (weeklyPass+weekDayApp);

        case 'tuesday':
        case 'wednesday':
        console.log (weeklyPass+'wsdnsd');
        case 'thursday':
        console.log (weeklyPass+'thrsd');
        case 'friday':
        console.log (weeklyPass+'frd');
        case 'saturday':
        console.log (weeklyPass+'strd');
        case 'sunday':
        console.log (weeklyPass+'snd');

A bold está já uma versão alternativa, mas já tive o código todo sem considerar a variável weekDayApp, apenas acrescentando as consoantes de cada palavra.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.