1009
JavaScript (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] kubica@fedia.io 24 points 2 weeks ago

Lets fix it. I think that since we are removing the ones, then "11" - 1 should be equal to "".

[-] r00ty@kbin.life 15 points 2 weeks ago

Should it, or should it be "1"? (just removing one, one)

[-] grue@lemmy.world 4 points 2 weeks ago

Which "1" did it remove? And did it search the string to find a "1" to remove, or did it remove whichever character happened to be at array index 1?

[-] FooBarrington@lemmy.world 4 points 2 weeks ago

It should just randomly pick any "1". Add a bit of spice, you know

[-] anton 3 points 2 weeks ago

maybe we removed the last n characters

[-] Shanmugha@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks ago)

Hear me out:

"11" - 1 = "11" - (-1) = "11" (did not find "-1" in "11)

Or

"11" - 1 = "11" - (-1) = "1" (removed first "1")

this post was submitted on 04 Jun 2025
1009 points (100.0% liked)

Programmer Humor

24287 readers
438 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS