How to display a message when given number is between the range using JavaScript ? Last Updated : 15 Feb, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will learn to display a message when a number is between the given range using JavaScript. We take a number from the user and tell the user whether it is in between a range or not, in our case, the range is 1 to 10. Approach: We create a button and add a click event listener to it. When we click on button, a prompt is shown on the browser screen using the JavaScript prompt() function asking for input. The variable is checked if it's in between the range or not by using the JavaScript if-else statement. If this input is in between the range, we show a success message on the screen using the innerHTML property otherwise, we show a failure message. Example: HTML <div> <h1 style="color:green">GeeksforGeeks</h1> <button onclick="fun()"> click me </button> <p id="gfg2"></p> </div> <script> function fun() { const input = prompt('Please enter a number:'); if (input >= 1 && input <= 10) document.getElementById("gfg2") .innerHTML = input + " Success!"; else document.getElementById("gfg2") .innerHTML = input + " Fail!" } </script> Output: How to display a message when given number is between the range using JavaScript ? Comment More infoAdvertise with us Next Article How to display a message when given number is between the range using JavaScript ? K KapilChhipa Follow Improve Article Tags : JavaScript Web Technologies HTML JavaScript-Numbers JavaScript-Methods JavaScript-Questions +2 More Similar Reads How to Print a Message to the Error Console Using JavaScript ? This article will show you how to print a message using JavaScript on the error console. There are three methods to display the error console, these are: Table of Content Using console.error() MethodUsing console.warn() MethodUsing console.info() MethodApproach 1: Using console.error() MethodThe con 2 min read JavaScript Program to Display Prime Numbers Between Two Intervals Using Functions Prime numbers are natural numbers greater than 1 that are only divisible by 1 and themselves. In this article, we will explore how to create a JavaScript program to display all prime numbers between two given intervals using functions. Approach 1: Using Basic Loop and FunctionThe most straightforwar 2 min read JavaScript Program to Display Armstrong Number Between Two Intervals An Armstrong number is a number that is equal to the sum of its digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153. In this article, we'll explore how to create a JavaScript program to display all Armstrong numbers within a 2 min read How to force Input field to enter numbers only using JavaScript ? We are going to learn how can we force the Input field to enter numbers only using JavaScript. Below are the approaches to force input field force numbers using JavaScript:Table of ContentBy using ASCII ValueBy using replace(), isNan() functionBy using ASCII ValueIn this approach, we are going to us 3 min read How to create a Number object using JavaScript ? In this article, we will discuss how to create a Number object using JavaScript. A number object is used to represent integers, decimal or float point numbers, and many more. The primitive wrapper object Number is used to represent and handle numbers. examples: 20, 0.25. We generally don't need to w 2 min read Like