Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Returning the nth even number using JavaScript
Problem
We are required to write a JavaScript function that takes in a number n. And our function should simply return the nth even number in natural numbers.
Example
Following is the code −
const num = 67765;
const nthEven = (num = 1) => {
const next = num * 2;
const res = next - 2;
return res;
};
console.log(nthEven(num));
Output
135528
Advertisements
