Hi everyone,
As you may know, there is no way in JavaScript to determine whether or not a number is a multiple of another number, so I wrote this function.
function isMultiple(big, small){
return (big/small + "").indexOf('.') < 0;
}
Enter fullscreen mode Exit fullscreen mode
Now you can use this in your code as well. You’re welcome. Got any other tips for me? I am looking for functions, that can ease my programming life. Any programming language is appreciated.
EDIT: Some quick edit, because there seems to be confusion. This introductory text is supposed to be sarcastic. I know there is a %
operator. I know this function does not make sense and that it is super inefficient. The challenge is, that you should provide pieces of code that are (on purpose or not) weired or way too complicated or inefficient or useless.
暂无评论内容