Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys, i need to answer this urgent to can enter in my dream school to learn code:
you can 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.



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...

They already give the variables:
var weeklyPass = 'darlene';
var weekDay = 'friday';
var currentPass =;

What I have tried:

I tries this:

<pre>var weeklyPass = 'darlene';
var weekDay = 'friday';
var currentPass = weekDay;




switch (currentPass) {
    case 'monday':
        console.log(weeklyPass + 'mnd');
break;
    case 'tuesday':
        console.log(weeklyPass + 'tsd');
break;
    case 'wednesday':
        console.log(weeklyPass + 'wdnsd');
break;
    case  'thursday':
        console.log(weeklyPass + 'thrsd');
break;
    case 'friday':
        console.log(weeklyPass + 'frd');
break;
    case 'saturday':
        console.log(weeklyPass + 'strd');
break;
        default :
        console.log(weeklyPass + 'snd');
break;        
}
Posted
Updated 10-Dec-21 14:19pm
Comments
Richard MacCutchan 5-Dec-21 10:40am    
I just tried your code and it works fine. What is the problem?
lucas oliveira Dec2021 5-Dec-21 10:52am    
The program that i'm using is part of an app made for people who want to get into this school, and that's what the console tell me :
The code is incorrect. You should probably rethink what your switch statement is evaluating."
Richard MacCutchan 5-Dec-21 10:57am    
As I said, it works for me. You need to provide more information.
lucas oliveira Dec2021 5-Dec-21 11:05am    
So, for me works to. The code is right, but isn't in the form that they want.
I send them email and they reply this : Reread the question and try to better understand what you really have to have as cases to be analyzed and which variable has that value, maybe it's not what you're thinking.
Richard MacCutchan 5-Dec-21 11:46am    
Sorry, but I have no idea who "they" are, and why they do not like your code. You need to ask them what is wrong.

If I had set this exercise the first thing I would question is
JavaScript
switch (currentPass) {
    case 'monday':
At first glance that reads "switch on the current password" which is confusing as you are meant to be switching on the current day of the week so better for me would be
JavaScript
switch (weekDay) {
    case 'monday':
Your next problem is with
JavaScript
console.log(weeklyPass + 'mnd');
That should be
JavaScript
console.log(weeklyPass + 'mndy');
The letter 'Y' is only considered to be a vowel when there is no other vowel in the syllable - "day" already has an "a" so y needs to be thought of as a consonant. If in doubt, then "y" is a consonant.
 
Share this answer
 
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Start by reading the question rather more carefully and think about exactly what you have to do. Hint: is "Y" a vowel?

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
lucas oliveira Dec2021 5-Dec-21 9:41am    
Hi OriginalGriff, I've been stuck with this issue for 3 days. It was not my goal to ask you to do the work for me. They say that in this case 'Y' is not a vowel. I don't understand if my cases are correct or not, or if I'm doing the wrong switch statement
OriginalGriff 5-Dec-21 10:11am    
So what have you tried?
What does the debugger show you?
lucas oliveira Dec2021 5-Dec-21 10:21am    
I tried this:
var weeklyPass = 'darlene';
var weekDay = 'friday';
var currentPass = weekDay;




switch (currentPass) {
case 'monday':
console.log(weeklyPass + 'mnd');
break;
case 'tuesday':
console.log(weeklyPass + 'tsd');
break;
case 'wednesday':
console.log(weeklyPass + 'wdnsd');
break;
case 'thursday':
console.log(weeklyPass + 'thrsd');
break;
case 'friday':
console.log(weeklyPass + 'frd');
break;
case 'saturday':
console.log(weeklyPass + 'strd');
break;
default :
console.log(weeklyPass + 'snd');
break;
}

The debugger tell me : The code is incorrect. You should probably rethink what your switch statement is evaluating.
And I've already rethought But I don't know why I'm not getting it man... I've tried a lot of different things...
OriginalGriff 5-Dec-21 10:41am    
"The debugger tell me : The code is incorrect. You should probably rethink what your switch statement is evaluating."
No, it doesn't.
You do know how to use a debugger, don't you?
lucas oliveira Dec2021 5-Dec-21 10:48am    
I know.
The program that i'm using is part of an app made for people who want to get into this school, and that's what the console is answering me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900