I was playing arround with some code and did this code that appears to be a infinit loop but I don't know why.
let battery = 100;
let hackedTerminals = 0;
const welcomeMessage = 'fSociety distro is booting... Please enter your
username: ';
const username = 'Samuel';
console.log(welcomeMessage + username);
const batteryLeft = () =>{
battery ? console.log('I\'ve still got ' + battery + '% battery. Let\'s hack some more targets!'):
console.log('I\'m out of battery. I was able to hack ' + hackedTerminals + 'termonals.')
}
const totalTries = 3;
let attempts = 0;
const failedAttemptMessage = 'Wrong password... Keep trying, Hackerman!';
let wipedData = false;
Here the infinite loop
function tryHack(){
attempts++
if (attempts >= 3){
wipedData = true;
}else{
wipedData = false;
}
wipedData ? console.log('All data has been deleted!'):
console.log(failedAttemptMessage)
tryHack()
}
tryHack()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.