mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-24 11:03:17 -04:00
fix(curriculum): allow positive numbers only for decimal to binary conversion (#54708)
This commit is contained in:
committed by
GitHub
parent
7700a4f450
commit
e70ef2a03f
@@ -13,6 +13,9 @@ All of the HTML and CSS for this project has been provided for you.
|
||||
|
||||
When you're ready to get started, use the `.getElementById()` method to get the input element with the id `number-input`, and store it in a variable called `numberInput`. Use the same method to get the button element with the id `convert-btn` and store it in a variable called `convertBtn`, and the `h2` element with the id `result` and store it in a variable called `result`.
|
||||
|
||||
|
||||
**NOTE**: This project will only convert positive numbers into binary.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the `document.getElementById()` method to get the `#number-input` element.
|
||||
|
||||
@@ -19,12 +19,21 @@ isNaN("3.5"); // false
|
||||
|
||||
Update the second condition in your `if` statement to use the `isNaN()` function to check if the value returned by `parseInt()` is `NaN`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should wrap the value returned by `parseInt()` in the `isNaN()` function.
|
||||
Also,as we mentioned in step 1 that we are considering only positive numbers, we should add a third condition in `if` statement to check whether the number is less than 0 (i.e negative numbers)
|
||||
|
||||
```js
|
||||
assert.match(String(checkUserInput), /if\s*\(\s*!\s*numberInput\s*\.\s*value\s*\|\|\s*isNaN\(\s*parseInt\(\s*numberInput\s*\.\s*value\s*\)\s*\)\s*\)\s*\{/);
|
||||
6 < 0; // false
|
||||
-1 < 0; // true
|
||||
-8 < 0; // true
|
||||
0 < 0; //false
|
||||
```
|
||||
|
||||
# --hints--
|
||||
|
||||
You should wrap the value returned by `parseInt()` in the `isNaN()` function. And add a third condition which checks the value returned by `parseInt()` to be less than 0.
|
||||
|
||||
```js
|
||||
assert.match(String(checkUserInput), /if\s*\(\s*!\s*numberInput\s*\.\s*value\s*\|\|\s*isNaN\(\s*parseInt\(\s*numberInput\s*\.\s*value\s*\)\s*\)\s*\|\|\s*parseInt\(\s*numberInput\s*\.\s*value\s*\)\s*\<\s*0\s*\)\s*\{/);
|
||||
```
|
||||
|
||||
The body of your `if` statement within `checkUserInput` should be empty.
|
||||
|
||||
@@ -9,7 +9,7 @@ dashedName: step-13
|
||||
|
||||
Now you can alert the user if they don't enter a number, or the number is invalid before you attempt to convert it into binary.
|
||||
|
||||
In the body of the `if` statement, use the `alert()` method to display the text `Please provide a decimal number`.
|
||||
In the body of the `if` statement, use the `alert()` method to display the text `Please provide a decimal number greater than or equal to 0`.
|
||||
|
||||
Note that `alert()` is a method on the `window` object in the browser, so you can use either `window.alert()` or `alert()`.
|
||||
|
||||
@@ -21,7 +21,7 @@ You should call the `alert()` method within the body of your `if` statement with
|
||||
assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(/);
|
||||
```
|
||||
|
||||
When there is a falsy value in the `#number-input` element and the `checkUserInput()` function is called, the `alert()` method should display the text `Please provide a decimal number`.
|
||||
When there is a falsy value in the `#number-input` element and the `checkUserInput()` function is called, the `alert()` method should display the text `Please provide a decimal number greater than or equal to 0`.
|
||||
|
||||
```js
|
||||
const numberInput = document.getElementById("number-input");
|
||||
@@ -31,7 +31,7 @@ window.alert = (message) => alertMessage = message; // Override alert and store
|
||||
numberInput.value = '';
|
||||
checkUserInput();
|
||||
|
||||
assert.strictEqual(alertMessage.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please provide a decimal number');
|
||||
assert.strictEqual(alertMessage.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please provide a decimal number greater than or equal to 0');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@@ -162,7 +162,11 @@ const convertBtn = document.getElementById("convert-btn");
|
||||
const result = document.getElementById("result");
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
@@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`.
|
||||
You should use the `return` keyword after `alert()`.
|
||||
|
||||
```js
|
||||
assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i);
|
||||
assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number greater than or equal to 0\2\s*\)\s*;?\s*return\s*;?\s*\}/i);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@@ -147,10 +147,14 @@ const convertBtn = document.getElementById("convert-btn");
|
||||
const result = document.getElementById("result");
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
--fcc-editable-region--
|
||||
alert("Please provide a decimal number");
|
||||
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
|
||||
--fcc-editable-region--
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,12 @@ const result = document.getElementById("result");
|
||||
--fcc-editable-region--
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,8 +161,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,8 +184,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,8 +191,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,8 +161,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,8 +161,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,8 +174,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,8 +167,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,8 +155,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -180,8 +180,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,8 +167,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,8 +172,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,8 +194,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +185,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,6 @@ const decimalToBinary = (input) => {
|
||||
|
||||
--fcc-editable-region--
|
||||
if (input === 0) {
|
||||
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
@@ -179,8 +178,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -196,8 +196,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,8 +151,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,8 +159,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,8 +168,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,8 +168,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,8 +172,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,8 +169,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,6 @@ const countdown = (number) => {
|
||||
if (number === 0) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
}
|
||||
--fcc-editable-region--
|
||||
};
|
||||
@@ -185,8 +184,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,8 +174,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,8 +194,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,8 +186,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,8 +175,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,8 +188,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,8 +191,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,8 +191,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,8 +194,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -196,8 +196,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,8 +191,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,8 +182,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -196,8 +196,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,8 +162,12 @@ const decimalToBinary = (input) => {
|
||||
--fcc-editable-region--
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,8 +161,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,8 +159,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -180,8 +180,12 @@ const decimalToBinary = (input) => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,8 +167,12 @@ const decimalToBinary = (input) => {
|
||||
--fcc-editable-region--
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -177,8 +177,12 @@ const showAnimation = () => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,12 @@ const showAnimation = () => {
|
||||
};
|
||||
|
||||
const checkUserInput = () => {
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -177,8 +177,12 @@ const checkUserInput = () => {
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,16 @@ Replace all instances of `parseInt(numberInput.value)` with `inputInt`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should replace `isNaN(parseInt(numberInput.value))` with `isNaN(inputInt)`.
|
||||
You should replace `isNaN(parseInt(numberInput.value))` with `isNaN(inputInt)` and `parseInt(numberInput.value) < 0` with `inputInt < 0`.
|
||||
|
||||
```js
|
||||
assert.notMatch(
|
||||
String(checkUserInput),
|
||||
/isNaN\(\s*parseInt\(\s*numberInput\s*\.\s*value\s*\)\s*\)/
|
||||
/isNaN\(\s*parseInt\(\s*numberInput\s*\.\s*value\s*\)\s*\)\s*\|\|s*\(\s*parseInt\(\s*numberInput\s*\.\s*value\s*\)\s*\<\s*0/
|
||||
);
|
||||
assert.match(
|
||||
String(checkUserInput),
|
||||
/isNaN\(\s*inputInt\s*\)/
|
||||
/isNaN\(\s*inputInt\s*\)\s*\|\|\s*inputInt\s*\<\s*0/
|
||||
);
|
||||
```
|
||||
|
||||
@@ -202,8 +202,12 @@ const checkUserInput = () => {
|
||||
--fcc-editable-region--
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
|
||||
alert("Please provide a decimal number");
|
||||
if (
|
||||
!numberInput.value ||
|
||||
isNaN(parseInt(numberInput.value)) ||
|
||||
parseInt(numberInput.value) < 0
|
||||
) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,8 +175,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,8 +199,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,8 +199,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,8 +179,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,8 +230,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,8 +220,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,8 +223,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,8 +190,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -203,8 +203,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-92
|
||||
|
||||
# --description--
|
||||
|
||||
Then, use the compound assignment operator (`+=`) to set the `innerHTML` property of the `animationContainer` to an empty template literal string.
|
||||
Then, use the compound assignment operator (`+=`) to set the `innerHTML` property of the `animationContainer` to an empty template literal string.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -185,8 +185,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,8 +195,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,8 +190,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,8 +201,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,8 +199,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,8 +192,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ Add the property `msg` to the animation object at the top of the stack, and set
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
|
||||
You should add the property `msg` to the animation object at the top of the stack.
|
||||
|
||||
```js
|
||||
@@ -206,8 +204,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +208,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -222,8 +222,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,8 +248,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -251,8 +251,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,8 +223,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,8 +207,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -216,8 +216,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -227,8 +227,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,8 +220,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,8 +233,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,8 +215,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,8 +427,8 @@ const showAnimation = () => {
|
||||
const checkUserInput = () => {
|
||||
const inputInt = parseInt(numberInput.value);
|
||||
|
||||
if (!numberInput.value || isNaN(inputInt)) {
|
||||
alert("Please provide a decimal number");
|
||||
if (!numberInput.value || isNaN(inputInt) || inputInt < 0) {
|
||||
alert("Please provide a decimal number greater than or equal to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user