Loops in JavaScript:

Basically just finally turning the pseudocode and what not that he had going on into real code with for loops and such. He does so for both the bubble sort and the insertion sort. He uses node as the framework to let him run Javascript outside of the browser pretty much.

I know how to write a for loop, I won’t get fucked over with the way that you write one in Javascript. You just set the loops to be from zero to the size of the array, for bubble sort at least, and then you have an inner loop with the same thing, and then you just compare the two bitches man.

Then for insertion sort you have the for loop with probably a while loop or in all honesty another for loop maybe inside of it, and then you just do the proper checks and implement the logic, here is some of the code he has, I mean it’s not for sorting or anything, it’s his fuck as morning routine:

Pasted image 20261114162650.png

Bubble Sort in JS

So he has a few things, for one he just creates a random array with the built in javascript random methods and what not, at least as it might seem for him to do right, in a given range this is, at least 10 elements it looks like.

But basically he does this and then he implements a swap function, this is obviously unnecessary but if you want to reuse it or whatever, cleaner code maybe, then you can, you just hold the element at a temporary position and then you overwrite it with the element you are swapping, then at the index you did not yet write into, you put that element that you saved at that index and then boom, a clean swap. Most standard libraries provide a swap function nowadays anywho but its whatever.

Then for the actual bubble sort it’s two nested for loops inside of each other, the outer one assures that each of the elements gets sorted into the highest place at a time, so each highest element is found and moved to the end of the array. The inner one is the one that compares all of the elements between each other, and then it swaps the two elements with the above mentioned swap function if the one at the previous index is smaller than the one at the current index, pretty calm cookies overall, more nuance of course but here is the code he did:

Swap function:
Pasted image 20261114163525.png

Bubble Sort and Comparison:
Pasted image 20261114163646.png

Introduction to Node JS Reading:

“IntroToNode.pdf” could not be found.

Intro to Node Notes:

Objectives:

  1. To give background info on Node. js and how to compile and run code using it
  2. To describe how to install Node.js
  3. To describe the use of the CLI to compile and run code
  4. To describe the use of Node to identify errors in code
  5. To describe and use an implementation of vectors and dynamic arrays using JS Arrays

What is Node?

So, standard JS generally runs inside a browser right. It runs code inside of a browser pretty much. Node however, allows google’s open source V 8 engine in order to run code outside of a web browser environment. That is exactly what Node is, a runtime environment for JS

This means that you can develop applications using JS without the need from also implementing things like HTML and CSS. You also therefore do not need an internet connection in order to mess around with Javascript, which I mean you can run shit on local host without an internet connection but sure.

Now, I KNOW, because I TOOK A COURSE, that node can be used for a lot more than just this, like the backend for frameworks like express or NextJS, it can be used for backend development and as far as I remember it has a really good package manager for making tools like web servers and all of that good stuff.

But basically, once you have Node installed, all you need to do is write code in a text editor or an IDE and then run and compile your JS through the command line. The CLI of course is the command line interface where you interact with your system through the use of commands, allowing you to do a lot of different things, from accessing files, creating, deleting, scripting, a lot of stuff.

Now, whenever writing your code, you can use a text editor but you want to make sure that your file is saved as a .js file as anything else will not be run as javascript in the node environment.

Now if you want to install node then for any of the normie gay people you can go through a browser on MAC or Windows, go to the main node website in order to download the latest version of node for your operating system and follow the directions they have on there. If you are on linux you can probably just install it with apt or whatever other amazing packet manager.

Pasted image 20261115171637.png

This is a few of the basic commands for basically how he just moves over into a given directory through the command line and then he actually had the person create the folder from the GUI but you can do so through the command line as well, touch is how you do it on linux but I do not know for windows or mac.

Either way, once you have your helloworld.js or whatever you want to make, type in your javascript code inside of it with whatever you wish to have happen, and then you can simply navigate to the same directory, or even in another directory pass in the path to the file and run it using node helloworld.js or node /your/path/to/helloworld.js in the terminal.

This will then run the code on your local machine and do whatever you programmed it to do.

Pasted image 20261115171939.png

Now, node will generally just blurt out the stack of whatever the fuck the issue is whenever you have an error, treat it like any other good programmer and ask big daddy Claude to go ahead and fix it up for you, I mean it generally is really simple, you read through it to see what went wrong and then you just fix it if it’s a syntax error, or try and work through it if its a logic error.

How dynamic Arrays and Vectors work in Javascript

I won’t go over how to declare them, you use var, the name, and then brackets, and you either add in elements or declare it empty.

You have a few properties built in of course, arr.length is the size of the array, you have things like indexing so arr[0] is the first element in the array or arr[arr.length-1] for the last item in the array. You can also obviously set values by indexing. Those are the really simple ones.

We also have more fun stuff like how to remove elements in a given spot, so arr.splice(2, 1) will remove only one element at the second index. This basically lets us splice our array however we want to though, so we can do things like arr.splice(1, 0, 10) this for example adds in a new element at the second element with the value of 10.

We can also have things like push or pop on the array if you want to treat it more as a built in stack. And a bunch of other things that can really just be done with splice. as a matter of fact, we even copy arrays with splice.

Now, the issue with trying to copy over an array to another variable in javascript is that because we cannot explicitly say what the fuck var means, it instead means that we need to use var arr2 = arr.splice() otherwise arr2 will just be a shallow copy / a reference in memory to the original array. Of course the splice function also allows us to splice however we want, so we can copy over only part of the array too

Pasted image 20261115172722.png

Here is also how we can have an implementation of some pseudocode into javascript code:

Pasted image 20261115172801.png

The output is then:

Pasted image 20261115172815.png

That concludes the introduction to Node and a bit of JS, really light stuff.