Navigate back to the homepage

# How to check if a number is between two values in javascript?

Infinitbility
JavaScript
June 4th, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To check if a number is between two values, Apply greater then and less than both conditions with and ( && ) operator. if get `true` means a number in a range.

Note: Here we are using && operator to reduce the number of codes, there have a lot of ways to do that

Today, I’m going to show How do I check if a number is between two values in javascript, here I will write some conditions and an `if... else` statement to check if a number is between a range or not.

Let’s start the today’s tutorial How do you check if the number is between two values in javascript?

In the following example

1. I will set low and high numbers
2. I will sample the input number example
3. Write greater than and less than conditions to check number is between range or not
`.css-1chxjt6{position:absolute;right:22px;top:24px;padding:8px 12px 7px;border-radius:5px;color:#6f7177;-webkit-transition:background 0.3s ease;transition:background 0.3s ease;}.css-1chxjt6:hover{background:rgba(255,255,255,0.07);}.css-1chxjt6[data-a11y="true"]:focus::after{content:"";position:absolute;left:-2%;top:-2%;width:104%;height:104%;border:2px solid var(--theme-ui-colors-accent,#6166DC);border-radius:5px;background:rgba(255,255,255,0.01);}@media (max-width:45.9375em){.css-1chxjt6{display:none;}}1const inputNum = 70;23const lowest = 30;4const highest = 150;56if (inputNum > lowest && inputNum < highest) {7  console.log('✅ inputNum is between values');8} else {9  console.log('⛔️ inputNum is NOT between values');10}`

In the above program, we have the highest and lowest values of desired range and use our condition to check the input number in two values or not.

let’s check the output.

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

### Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Request New Tutorial or Article on mail [email protected]

### Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

### Guide to use onflow flow-js-testing framework

Example of use onflow flow-js-testing framework with step by step guide.

June 3rd, 2022 · 1 min read

### How to create multiple nodes in the node-red single module?

Example of create multiple nodes in the node-red single module or package with step by step guide.

June 3rd, 2022 · 1 min read