while loop with a if statement is not printing my if statement
var rest = 0
while(rest <=10) {
rest ++;
console.log(rest);
if (rest == 10)
console.log('Done!')
while loop with a if statement is not printing my if statement
var rest = 0
while(rest <=10) {
rest ++;
console.log(rest);
if (rest == 10)
console.log('Done!')
A simpler way to approach this would be to use Date#getDay() to get the 0-6
index of the current day within the week and store the suffixes in an array with same indexing.
Then use the day index to retrieve the associated suffix.
const suffixes = ['snd','mnd','tsd','wdnsd','thrsd','frd','strd']
const weekPass = 'ABC_';
const day = (new Date()).getDay();
const pass = weekPass + suffixes[day];
console.log('Day index =',day, ', Passs =',pass )
Or just this
const currentPass = "aaa",
weekDay = new Date().getDay(), // 0-6 (sun-mon)
dayPass = currentPass + ['snd', 'mnd', 'tsd', 'wdnsd', 'thrsd', 'frd', 'strd'][weekDay];
console.log(dayPass)
Considering what you wrote, the first step to get it working would be to fix the switch syntax and the assignment of currentPass
like this:
var weekDay = 'Friday';
var currentPass = "this_week_password"; // this is the values they gave me
switch (weekDay) {
case 'Monday':
currentPass += 'mnd';
break;
case 'Tuesday':
currentPass += 'tsd';
break;
case 'Wednesday':
currentPass += 'wdnsd';
break;
case 'Thursday':
currentPass += 'thrsd';
break;
case 'Friday':
currentPass += 'frd';
break;
case 'Saturday':
currentPass += 'strd';
break;
case 'Sunday':
currentPass += 'snd';
break;
}
console.log(currentPass)