You could use something simple as Math.max(5, 10);

const numOne = 5;
const numTwo = 10;

console.log(`Bigger number is: ${Math.max(numOne, numTwo)}`);

Or if you absolutely 'have to' use switch statement, you can try something like this:

const numOne = 5;
const numTwo = 10;

switch(true) {
    case (numOne > numTwo):
        console.log(`Bigger number is ${numOne}`);
        break;
    case (numOne < numTwo):
        console.log(`Bigger number is ${numTwo}`);
        break;
    case (numOne === numTwo):
        console.log(`${numOne} is equal to ${numTwo}`);
        break;
     default: console.log(false, '-> Something went wrong');
}

Answer from Dženis H. on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript | MDN
The largest of the given numbers. Returns NaN if any of the parameters is or is converted into NaN. Returns -Infinity if no parameters are provided. Because max() is a static method of Math, you always use it as Math.max(), rather than as a method of a Math object you created (Math is not a constructor). Math.max.length is 2, which weakly signals that it's designed to handle at least two parameters.
🌐
LeetCode
leetcode.com › problems › two-sum
Two Sum - LeetCode
Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice.
Discussions

How to use math.max with array
I've found Mozilla Developer Network (MDN) to be a great resource for JavaScript documentation. In this particular case, the last of the three examples they give right at the top of the page for Math.max() is exactly what you're looking for. As a PSA, when looking for JS tips, skip w3schools entirely. You're welcome. More on reddit.com
🌐 r/Bitburner
11
7
October 28, 2021
How to find maximum between two numbers in javascript using switch case? - Stack Overflow
If for some reason you were given numbers you could explicitly cast them to booleans with something like case !!0: but that starts to get a little hard on the eyes. If your goal is to find the max of two numbers, Math.max(num1, num2) is hard to beat for readability. More on stackoverflow.com
🌐 stackoverflow.com
JavaScript Math.max() Explained with Examples
Math Max Math.max() is a function that returns the largest value from a list of numeric values passed as parameters. If a non-numeric value is passed as a parameter, Math.max() will return NaN . An array of numeric values can be passed as a single parameter to Math.max() using either spread ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
8
September 8, 2019
Create a function named max that accepts two numbers as arguments
You have solved the hard part! just Double check the syntax of writing a function in JavaScript and you should be fine. You are ask to Create a function named max that accepts two numbers as arguments. More on teamtreehouse.com
🌐 teamtreehouse.com
3
September 19, 2022
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript math.max() method
JavaScript Math.max() Method
September 1, 2008 - The Math.max() method in JavaScript accepts a set of arguments as parameters, finds the highest numeric value among it, and returns it. If no arguments are provided, -Infinity is returned, indicating that there is no maximum value.
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value. ... Math.max() is an ECMAScript1 (JavaScript 1997) feature.
🌐
Programiz
programiz.com › javascript › library › math › max
JavaScript Math max()
JavaScript Math trunc() The max() method finds the maximum value among the specified values and returns it. let numbers = Math.max(12, 4, 5, 9, 0, -3); console.log(numbers); // Output: 12 · The syntax of the max() method is: Math.max(number1, number2,...) Here, max() is a static method.
🌐
Medium
medium.com › @amirakhaled2027 › how-to-find-the-largest-of-two-numbers-in-javascript-6fac783be845
How to find the largest of two numbers in JavaScript - Amira Khaled - Medium
August 25, 2024 - How to find the largest of two numbers in JavaScript To find the largest of two numbers in JavaScript, you can use the Math.max() function. Here's an example: var number1 = 10; var number2 = 5; var …
Find elsewhere
🌐
Dmitri Pavlutin
dmitripavlutin.com › javascript-math-max-infinity
Why Math.max() Without Arguments Returns -Infinity
Math.max() is a built-in JavaScript utility function that determines the maximum number from the arguments. For example, let's determine the maximum of the numbers 1, 2 and 3:
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › maximum-of-two-numbers-in-javascript
Maximum of Two Numbers in JavaScript - GeeksforGeeks
July 23, 2025 - In JavaScript, you can find the maximum of two numbers using the Math.max() method. This method takes multiple arguments and returns the largest of them.
🌐
QuickRef.ME
quickref.me › home › how to clamp a number between two values in javascript - quickref.me
How to clamp a number between two values in JavaScript - QuickRef.ME
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function. Let's define this short function: const clamp = (val, min = 0, max = 1) => Math.max(min, Math.min(max, val));
🌐
FlatCoding
flatcoding.com › home › javascript math.max(): how to find the highest number
JavaScript Math.max(): How to Find the Highest Number - FlatCoding
June 27, 2025 - It returns the largest, which is 15. ... The function has two numbers and picks the larger one, processes both inputs to find the highest value, and returns 10 as the result of the comparison.
🌐
freeCodeCamp
forum.freecodecamp.org › guide
JavaScript Math.max() Explained with Examples
September 8, 2019 - Math Max Math.max() is a function that returns the largest value from a list of numeric values passed as parameters. If a non-numeric value is passed as a parameter, Math.max() will return NaN .
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-math-max-method
JavaScript Math max() Method - GeeksforGeeks
September 30, 2024 - The Math.max() method in JavaScript returns the largest value from a set of zero or more numbers.
🌐
Built In
builtin.com › articles › javascript-array-max
3 Methods to Find the JavaScript Array Max | Built In
February 16, 2024 - More on JavaScriptHow to Pass an Array From Java to JavaScript · In this traditional approach, we loop through each element in the array and compare it with a previously stored maximum value. If the current element is greater, we update our maximum. let numbers = [3, 7, 2, 8, 5]; let max = numbers[0]; // initialize to the first value for (let i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } console.log(max); // Outputs: 8
🌐
Math.js
mathjs.org › docs › reference › functions › max.html
math.js | an extensive math library for JavaScript and Node.js
math.max(2, 1, 4, 3) // returns 4 math.max([2, 1, 4, 3]) // returns 4 // maximum over a specified dimension (zero-based) math.max([[2, 5], [4, 3], [1, 7]], 0) // returns [4, 7] math.max([[2, 5], [4, 3], [1, 7]], 1) // returns [5, 4, 7] math.max(2.7, 7.1, -4.5, 2.0, 4.1) // returns 7.1 math.min(2.7, ...
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Math › max
JavaScript Math max() - Find Maximum Value | Vultr Docs
November 27, 2024 - The Math.max() method in JavaScript is a straightforward yet powerful tool used to determine the maximum value among its given arguments. By accepting multiple numbers or an array of numbers (with a spread operator), this method evaluates and ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_SAFE_INTEGER
Number.MAX_SAFE_INTEGER - JavaScript | MDN
Number.MAX_SAFE_INTEGER represents ... The largest representable number in JavaScript is actually Number.MAX_VALUE, which is approximately 1.7976931348623157 × 10308....
🌐
W3Schools
w3schools.com › java › ref_math_max.asp
Java Math max() Method
The max() method returns the number with the highest value from a pair of numbers. Tip: Use the min() method to return the number with the lowest value. ... If you want to use W3Schools services as an educational institution, team or enterprise, ...