Thursday, January 29, 2026
Latest:
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
  • How Spring framework resolves circular dependencies?
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

How to get total days between two dates in JavaScript?

December 22, 2018 beroza

Why Test-Driven Development (TDD) is important?

October 1, 2022 beroza

What are the differences between Map vs Object in JavaScript?

August 30, 2021 beroza

How to prevent a log file from being too big using logrotate?

June 9, 2021 beroza

How to compare two objects in JavaScript?

August 28, 2021 beroza

What is a web.xml and why we need web.xml?

November 26, 2019 beroza

if-else statements inside JSX does not work in ReactJS

September 5, 2019 beroza

What is Java annotation? Write some facts about Java annotation

January 25, 2019 beroza

Write a program to remove palindromic subsequences from string

June 16, 2022 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.