Commit 2732e264 authored by Tapio Mäntysalo's avatar Tapio Mäntysalo
Browse files

Task 4 now works. I guess.

parent 82a78d74
......@@ -63,9 +63,6 @@
(high - low + 1));
</p>
<hr>
<div class="alert alert-danger" role="alert" id="alert-task-4">
This is a danger alert—check it out!
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Guess number between 1 and 100</span>
......@@ -76,6 +73,9 @@
<p>
<button type="button" class="btn btn-primary" id="btn-task-4">Guess</button>
</p>
<div class="alert alert-danger" role="alert" id="alert-task-4">
This is a danger alert—check it out!
</div>
<div class="alert alert-success" role="alert" id="alert-task-4-result">
</div>
</div>
......
......@@ -2,13 +2,13 @@ const guessMin = 1;
const guessMax = 100;
let target = -1;
$("#card-task-4-result").text("");
$('.input-task-4').val(((guessMax - guessMin) / 2).toFixed(0));
$("#alert-task-4").hide();
$("#alert-task-4-result").hide();
function initTask4() {
target = getRandomInteger(guessMin, guessMax);
$("#card-task-4-result").text("");
$('.input-task-4').val(((guessMax - guessMin) / 2).toFixed(0));
$("#alert-task-4").hide();
$("#alert-task-4-result").hide();
$("#btn-task-4").show();
}
......@@ -18,11 +18,11 @@ $("#input-task-4").keyup(function () {
let guess = +$("#input-task-4").val();
if (guess < 1) {
$("#alert-task-4").text("You should enter number greater than or equal to 1");
$("#alert-task-4").text("You should enter a number greater than or equal to 1");
$("#alert-task-4").show();
}
else if (guess > 100) {
$("#alert-task-4").text("You should enter number smaller than or equal to 100");
$("#alert-task-4").text("You should enter a number smaller than or equal to 100");
$("#alert-task-4").show();
}
else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment