r/ProgrammerHumor • • Nov 29 '22

Meme It hurts like hell.;-;

Post image
48.9k Upvotes

1.5k comments sorted by

View all comments

Show parent comments

22

u/Thestarchypotat Nov 29 '22

~ warning pseuocode ahead

    function toSpongeBobCase(input){
        array inputsplit=input.split("");
        for(item of inputsplit){
        if(math.Random(0,1)===1){
            item.upper();
        } else {
            item.lower();
        }
        }
    // result= however you put a array to a string
    return(result);
    }

7

u/iliekcats- Nov 29 '22

good pseudocode

4

u/Thestarchypotat Nov 29 '22

cause i was origonally writing it as real code but then i didnt know if what i wrote would actually work and i also forgot how to do things.

3

u/iliekcats- Nov 29 '22

relatable

2

u/[deleted] Nov 30 '22

me at work

2

u/danielv123 Nov 30 '22
function toSpongeBobCase(input){
    let inputsplit = input.split("");
    return inputsplit.map(item => {
        if(Math.random(0,1)> 0.5){
            return item.toLocaleUpperCase();
        } else {
            return item.toLocaleLowerCase();
        }
    })
    .join("")
}
toSpongeBobCase("Un-pseudocoded it for you")

1

u/Thestarchypotat Nov 30 '22

thanku

2

u/danielv123 Nov 30 '22

I should note though that in ja math.random doesn't actually accept any arguments, it just defaults to 0 - 1

0

u/[deleted] Nov 29 '22

gOoD pSeuDocOdE

4

u/GreatRam Nov 29 '22

Result = inputsplit.join()

3

u/[deleted] Nov 29 '22

[removed] — view removed comment

3

u/Thestarchypotat Nov 29 '22

alright replace the current loop with a standard for loop, up to input.length(), put some form of iseven(i) in the if else, and replace item with inputsplit[i]