6

Javascript makes me wanna blow my fucking brains out.

Why the fuck isn't appendChild working? It shouldn't be this fucking hard to get a simple result.

p = document.createElement("p");
p.textContent = String(new Date().getTime());
doc = document.getElementById("todoList")
doc.appendChild(p);

Done from within a listener function for another element, listening for onkeyup. Using bulma.

Jesus fucking christ and this is the profession I chose.

At this rate by the time I'm fucking competent I'll be replaced by wage slaves from india who started training at the age of ten because their government actually gives a shit about investing in their people instead of saddling new generations with trillions in bank debt so goldman fucking sachs can hire more underage prostitutes from epstein and mossad.

Comments
  • 7
    Call var on everything, double check DOM types, semi colons.

    Js sucks but is also super powerful but also will make you contemplate suicide
  • 2
    Maybe it’s an issue with your listener? Is it triggering the way you expect it to? Do you have some other changes that might be refreshing the DOM to the wrong state?
  • 10
    Have you considered that TODAY FUCKING SUCKS and that NOTHING IS MAKING A DAMNED BIT OF SENSE?

    Because that’s probably why.
  • 2
    @Root You too, huh?
  • 2
    Your code works as expected:

    <html>
    <head>
    <script>
    function test() {
    p = document.createElement("p");
    p.textContent = String(new Date().getTime());
    doc = document.getElementById("todoList")
    doc.appendChild(p);
    }
    </script>
    </head>
    <body onload="test();">
    <div id="todoList"></div>
    </body>
    </html>

    By any chance, is your code executing BEFORE the page loads? Like, is it NOT in a function like I did here? If so, that's your problem (and that's my guess) because the target element isn't in the DOM until the onload event fires (or you could move the script to the bottom of the document, then it would work as "naked" code in a script block).
  • 0
    @fzammetti

    Yep that was one of the issues

    @M1sf3t I think svelte is awesome, but I'm trying to really grasp everything at the basics. And since I learned that I *really* don't retain anything *at all* from practice, I started using flashcards and am basically retaining everything now, with the added bonus that all the improvisation of the past from failing so god damn much means the more advanced stuff is easier to grasp than the basics.

    Like a god damn autistic.

    I figured out that adding event attributes to elements in html, you use the 'on' prefix, but when using the element method .addEventListener, you pass in the event as a string and throwaway the 'on' prefix. So if you wanted an 'onkeyup' event in html, thats just what you would call it, but in javascript you

    would do 'element.addEventListener("keyup", someFunction).

    Was not helped by the fact that I had so many god damn problems finding a single source that points this out.

    Need a gotchas list for newbs.
  • 0
    @M1sf3t I'm mostly learning because I have dozens of viable ideas (who doesn't) and the marketing experience to raise the money, but zero startup capital, no ability to prototype atm, and no network connections. Also, if I don't understand the fundamentals and go for work in this career without the basics, I'd feel like a massive fraud.

    So its 1. start at a company, 2. save for an initial mvp, 3. network for a while, 4. don't quit the day job because the day job pays the bills and working for others is a good way to stay on your toes, 5. make a product or service.

    Five year plan. How about you Misfit?
  • 2
    @M1sf3t
    I mean, if we're being honest, he'll be replaced by some kid from India regardless of whether or not he's skill equivalent. That style of cost cutting is just where the industry is headed.
  • 0
    @M1sf3t It's not like the job at the scale house will prevent you from going elsewhere later, but I grok the reasons why its an either/or problem. Theres getting stuck in one place, or getting too comfortable, the time it takes out of your day when you could be studying, being too tired before or after work to do anything.

    Just know that a year from now you won't have the same problems to solve than today's problems.
  • 1
    @Matthewb console.log is your friend in js :)
  • 1
    @Wisecrack
    You could get a little creative as well to make it more attractive :)

    ex: https://stackblitz.com/edit/...
  • 0
    @M1sf3t I prefer typescript to :)
  • 0
    @M1sf3t
    Guiding people to the FP style 😘
  • 0
    @M1sf3t hey, have you ever taken pluralsights "skillIQ" test? Its free (just requires registration). if you could go do that, and get back to me with a screenshot, dont go passing up other opportunities (because im a commitment phobe), but I know a guy with a company who pays good and is supposed to be hiring soon. He reserved a spot for me at one point because we got on well but I really didnt know anything about web dev at the time. I think his entry test was to grab some data from amazon api and write some mock tests /validation, but at the time all I knew was python not javascript.

    Go do the skill iq test and get back to me.
  • 0
    @SortOfTested maybe, but I see companies like 37signals with services like hey.com doing it right, focusing more on innovation to lead profit matgin over cost cutting as a strategy.

    who would want to work for a company where their product strategy is to ignore the product anyway?
  • 1
    @Wisecrack
    I'm just focused on the original example code 😘

    Gotta be honest, never been terribly impressed with the 37signals offerings, but they don't target me.
  • 0
    also for the record im not illiterate i just cant type for shit on this tiny keyboard.
  • 0
    @M1sf3t thats what he offered me at the time.
  • 1
    @M1sf3t I am not sure I understand?
    Have I said ts was instant disqualification?
  • 0
    @M1sf3t ok :). Yes that sounds more like me :P
  • 0
    @M1sf3t thats not for him, thats for me so I know im recommending someone whos at least proficient. If you can write tests with a testibg framework you should be fine.
  • 0
    @M1sf3t I could and would. Lets talk, got an email or chat?
  • 0
    @M1sf3t hey protonmaik is my jam. Got scrabble night with the kids, but Ill hit you up tonight, see wgat you're thinking, got a bunch of questions, and we'll go from there.
Add Comment