Added results for exo 1.
This commit is contained in:
1 parent
187f2f581d
commit
9d9bb663d3
2 files changed
+40
-3
No files matched your search
@@ -82,10 +82,10 @@
|
|||||||
<button type="button" class="button is-warning" id="button-2" onclick="exo1c()" >#button-2</button>
|
<button type="button" class="button is-warning" id="button-2" onclick="exo1c()" >#button-2</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<button type="button" class="button is-primary is-light" id="button-3">#button-3</button>
|
<button type="button" class="button is-primary is-light" id="button-3" onclick="exo1d()">#button-3</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<button type="button" class="button is-warning is-light" id="button-4">#button-4</button>
|
<button type="button" class="button is-warning is-light" id="button-4" onclick="exo1e()">#button-4</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+38
-1
@@ -17,5 +17,42 @@ function exo1c(){
|
|||||||
let input2 = document.getElementById("input-2").value;
|
let input2 = document.getElementById("input-2").value;
|
||||||
|
|
||||||
document.getElementById("result-box-2").innerText = getInputEqualityMessage(input1, input2);
|
document.getElementById("result-box-2").innerText = getInputEqualityMessage(input1, input2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function isNumber(str) {
|
||||||
|
return str !== "" && !isNaN(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIsNumberMessage(input) {
|
||||||
|
if(isNumber(input)){
|
||||||
|
return "Number!";
|
||||||
|
}
|
||||||
|
return "n'est pas un nombre";
|
||||||
|
}
|
||||||
|
|
||||||
|
function exo1d(){
|
||||||
|
let input1 = document.getElementById("input-3").value;
|
||||||
|
|
||||||
|
document.getElementById("result-box-3").innerText = getIsNumberMessage(input1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSizeMessage(n) {
|
||||||
|
if(n < 1000){
|
||||||
|
return "plus plus petit que 1000";
|
||||||
|
}
|
||||||
|
return "plus plus grand que 1000";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSafeSizeMessage(input) {
|
||||||
|
if(!isNumber(input)){
|
||||||
|
return "n'est pas un nombre";
|
||||||
|
}
|
||||||
|
return getSizeMessage(parseInt(input));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function exo1e(){
|
||||||
|
let input1 = document.getElementById("input-4").value;
|
||||||
|
|
||||||
|
document.getElementById("result-box-4").innerText = getSafeSizeMessage(input1);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user