Sunday, October 5, 2025
Latest:
  • German Pronouns with Nominative, Accusative, and Dative cases
  • German articles for the nominative, accusative, and dative cases
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
Upokary

Upokary

Quality information

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

Find next higher natural number that is divisble by another number

Published: February 11, 2022Last updated: February 11, 2022

Write a function that takes two numbers, say x and y, as arguments. We need to check if x is divisible by y. If yes, then return x. If not, return the next higher natural number that is divisible by y.

const findDivisble = (x, y) => {
   if (x % y === 0) return x;

   if(y < 0) return 0;

   const divisor = parseInt(x / y);
   return divisor * y + y;
}

console.log(findDivisble(7, 3)); // 9

You May Also Like

Is there a print_r or var_dump equivalent in Ruby on Rails?

May 27, 2020 beroza

Traverse array of objects recursively in JavaScript

February 13, 2022 beroza

How to do function overloading in TypeScript?

November 15, 2021 beroza

How to redirect a page using ReactJS?

May 3, 2020 beroza

What is memory leak? How to avoid memory leak in JavaScript?

August 14, 2021 beroza

What is Cross-Site Request Forgery (CSRF)? Why CSRF is important?

September 4, 2022 beroza

error reading tomcat-embed-core.jar; zip file is empty

January 30, 2019 beroza

Why we should use ‘use strict’ in JavaScript?

August 13, 2021 beroza

How to support multiple languages in ReactJS application?

March 9, 2020 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 © 2025 Upokary. All rights reserved.