
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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
- Related Articles
- Returning the value of nth power of iota(i) using JavaScript
- Find the Nth Even Length Palindrome using C++
- Program to find Nth Even Fibonacci Number in C++
- Returning the first number that equals its index in an array using JavaScript
- Returning number with increasing digits. in JavaScript
- Returning the highest number from object properties value – JavaScript
- Returning the expanded form of a number in JavaScript
- Finding the nth prime number in JavaScript
- Splitting number to contain continuous odd or even number using JavaScript
- Returning reverse array of integers using JavaScript
- Returning only odd number from array in JavaScript
- Returning an array containing last n even numbers from input array in JavaScript
- Returning number of digits in factorial of a number in JavaScript
- Returning lengthy words from a string using JavaScript
- JavaScript to Calculate the nth root of a number

Advertisements