Thursday, July 30, 2026
Latest:
  • Präsentation für b1
  • Verb “werden” Konjugation
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Return the next higher prime number

Published: February 11, 2022

Write a function that takes a number (a) as argument. If a is prime number, return a. If a is not prime number then return the next higher prime number.

const nextPrimeNumber = (num) => {
    for(let i = 2; i < num ; i++) {
        if(num % i === 0) {
            return nextPrimeNumber(num + 1)
        }

    }
    return num;
};

const input = 90;
console.log(nextPrimeNumber(input)); // 97

You May Also Like

ReferenceError: localStorage is not defined

April 10, 2021 beroza

What is JavaScript closure and how it works?

January 28, 2019 beroza

In which order static initialisation block and constructor run in java?

September 16, 2019 beroza

How to update Node.js and npm to the latest version?

June 15, 2022 beroza

How to check variable is an object in JavaScript?

August 13, 2021 beroza

What are the differences between inline vs inline-block?

May 9, 2019 beroza

What are the WordPress REST API endpoints ?

July 4, 2019 beroza

Remove a trailing slash from a string (i.e. string) in java

December 10, 2019 beroza

Interfaces vs Types alias in TypeScript

November 10, 2021 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2026 Upokary. All rights reserved.