Jump to content
DianaRCBA

Switch Statement | Como construir uma password

Recommended Posts

DianaRCBA

Olá, 

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);
            break;

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

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.

 

Obrigada
Diana

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.