10-5 Please fix my code D:


#1

Hey guys, i'm a beginner coder That can't really code
Can you fix this code i made :smiley:

var speed = math.floor(math.random()*5);
var accuarcy = math.floor(math.random()*99);
var PasAb = if ( 0 < speed =< 3) {
    PasAb === false;
    }
    else {
        PasAb === true;
        }
var AccAb = if ( 0 < accuarcy < 50) {
    AccAb === false;
    else {
        AccAb === true;
    }
var user = prompt("you are running with the ball with you, PASS it to your friend, SHOOT for a goal, or keep RUNning?");
switch (user) {
    case 'PASS':
        if (PasAb && AccAb) {
        console.log("You tried to pass, the enemy got the ball")};
        else {
            console.log("Your attempt was unsuccessful"); }
        break;
    case 'SHOOT':
        if (AccAb) {
        console.log("SHOTS FIRED, GOAAL")
        }
        else {
            console.log("Shots fired, BUT IT MISSED :(");
        }
        break;
    case 'RUN':
        if (speed) {
        console.log("YOu are still running");
        }
        else {
            console.log("They took the ball");
        }
        break;
    default : 
        console.log("It failed");
        break;
}

Thanks <3


#2
var speed = Math.floor(Math.random() * 5);
var accuracy = Math.floor(Math.random() * 99);
var PasAb = !(speed > 0 && speed <= 3);

console.log(speed, accuracy, PasAb);

var AccAb = function() {
    AccAb = !(accuarcy > 0 && accuracy < 50);
    var user = prompt("you are running with the ball with you, PASS it to your friend, SHOOT for a goal, or keep RUNning?");
    switch (user) {
        case 'PASS':
            if (PasAb && AccAb) {
                console.log("You tried to pass, the enemy got the ball");
            } else {
                console.log("Your attempt was unsuccessful");
            }
            break;
        case 'SHOOT':
            if (AccAb) {
                console.log("SHOTS FIRED, GOAAL");
            } else {
                console.log("Shots fired, BUT IT MISSED :(");
            }
            break;
        case 'RUN':
            if (speed) {
                console.log("YOu are still running");
            } else {
                console.log("They took the ball");
            }
            break;
        default:
            console.log("It failed");
            break;
    }
};

AccAb();