DEV Community

Discussion on: Challenge: Write your worst program

Collapse
 
isaacdlyman profile image
Isaac Lyman • Edited

Can I suggest an improvement to your program? It turns out that there is an operator for doing exactly that in JavaScript.

function isMultiple(big, small) {
  return big % small === 0;
}

The modulo operator retrieves the remainder of division, which is always 0 for whole multiples.

Collapse
 
r0f1 profile image
Florian Rohrer

Hi, thank you for your response. Of course, I know about the modulo operator. This challenge was supposed to be about your worst programs. And as an example I posted this function that divides two numbers, casts the result to a string, searches the whole string for a comma and returns whether a comma was found or not instead of just using %. This is pretty bad in my view. I thought you (the community) might have some other terrible examples like this.

Collapse
 
isaacdlyman profile image
Isaac Lyman

Ohhhhh. I definitely missed that nuance in your original question. My mistake.