Problem 1 - Password Reset softuni js
function password(inp){
let count = 0
let sum = ''
let sentencetoworkat = inp.shift()
console.log(sentencetoworkat);
while(inp[0] != "Done"){
let tokens = inp.shift().split(' ')
let name = tokens[0]
let p1 = tokens[1]
let p2 = tokens[2]
switch(name){
case"TakeOdd":
for(let el of sentencetoworkat){
if(count !== 0){
if (count % 2 !== 0 || count == 1){
sum += el
}}
count++
}console.log(sum);
break;
case "Cut":
let thisarr = sum.split('')
let spliced = thisarr.splice(p1,p2)
thisarr = thisarr.join('')
console.log(thisarr);
sum = thisarr
break;
case"Substitute":
if(sum.includes(p1)){
let replaced = sum.split(p1).join(p2)
sum = replaced
console.log(sum);
}
else{console.log("Nothing to replace!")}
break;
}
}
console.log(`Your password is: ${sum}`);
}
50/100
някой да вижда проблема