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