> ## Documentation Index
> Fetch the complete documentation index at: https://blog.sumathi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

#  Exercise 2 Snake Water Gun

* Use Javascript to create a game of snake , water & gun . The game should ask you to enter S,W or G . The computer should be able to randomly generate S,W or G and declare win or loss using alert . Use confirm and prompt wherever required

```js theme={null}
validInputs = [ "S" , "W" , "G"]

let askAgain = true;
function check(user, computer) {
    if (user === computer) return "It's a tie!";
    if (
        (user === "S" && computer === "W") ||
        (user === "W" && computer === "G") ||
        (user === "G" && computer === "S")
    ) {
        return "You win!";
    } else {
        return "You lose!";
    }
}
while (askAgain) {
    askAgain = false;
    let input = prompt("Enter S or W or G").toUpperCase();
    let comp_input = validInputs[Math.floor(Math.random() * (2 - 0 + 1)) + 0];
    document.write(input)
    if (validInputs.includes(input)) { alert(check(comp_input,input)); break}
    else {askAgain = true}
}
```
