Skip to content

Instantly share code, notes, and snippets.

@devded
Created May 16, 2022 19:16
Show Gist options
  • Save devded/ccb41336793f5ca938bb02a29cfb117d to your computer and use it in GitHub Desktop.
Save devded/ccb41336793f5ca938bb02a29cfb117d to your computer and use it in GitHub Desktop.
minimumQuantity = [0, 11, 21, 31, 41, 51, 61, 71, 81, 91]
maximumQuantity = [4, 20, 30, 40, 50, 60, 70, 80, 90, 100];
// check number in minimumQuantity and maximumQuantity in range
const checkNumber = (number) => {
for (let i = 0; i < minimumQuantity.length; i++) {
if(number >= minimumQuantity[i] && number <= maximumQuantity[i]){
return false;
}
}
return true
}
// check number is in minimumQuantity and minimumQuantity
const insertData = (data_a, data_b) => {
is_data_a_valid = checkNumber(data_a);
is_data_b_valid = checkNumber(data_b);
if(is_data_a_valid && is_data_b_valid){
console.log("Data is valid");
console.log(data_a+data_b);
}else{
console.log("Data is invalid");
}
}
insertData(5, 11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment