<!DOCTYPE html> <html> <head> <title>Crash Game</title> </head> <body> <button onclick="startGame()">Start Game</button> <p id="result"></p> <script> function startGame() { // Generate a random time frame between 5 and 10 seconds const minTime = 5; const maxTime = 10; const timeInSeconds = Math.floor(Math.random() * (maxTime - minTime + 1) + minTime); // Set a timeout to simulate the game crash after the specified time setTimeout(function() { // Generate a random crash result (win or loss) const crashResult = Math.random() < 0.5 ? 'Win' : 'Loss'; // Display the result document.getElementById('result').innerText = 'Game ' + crashResult + ' at ' + timeInSeconds + ' seconds!'; }, timeInSeconds * 1000); // Convert time to milliseconds } </script> </body> </html>
Write, Run & Share Bash code online using OneCompiler's Online Bash Shell for free. It's one of the robust, feature-rich Bash shell available over online and getting started with the OneCompiler's Bash Shell is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Bash
. OneCompiler also has reference scripts, where you can look for the sample scripts and start coding.
Bash (Bourne Again Shell) is a shell program written by Brian Fox and is an upgraded version of Bourne Shell program 'sh'.
name="Foo"
echo $name
echo "$name"
echo "${name}"
if [ conditional-expression ]
then
statements
fi
if [ conditional-expression ]
then
statements
else
statements
fi
if [ conditional-expression ]
then
statements
elif [ conditional-expression ]
then
statements
else
statements
fi