python jargon

Jargon differences in JavaScript

While doing a coding challenge for a job application, I ran into an issue where jargon from other languages were used that I was unfamiliar with.

Segment:

In Python, it’s called a segment but in JavaScript, it’s a slice. If asked about a segment, it’s asking about a sliced section of an Array, string, Typed Array or NodeList.

Vector/List:

In Python, arrays are most commonly referred to as lists but can also be referred to as ‘Vectors’

“Heaps and Hashmaps/Dictionaries”

Heaps are a special type of tree that doesn’t exist in JavaScript. Hashmaps are essentially Javascript Objects.

Tuples

In python, tuples are ordered, immutable collections of elements that JavaScript doesn’t have a counterpart for.

def

Probably not super helpful but to define a function, ‘def’ is used in Python.

There are other differences but these seemed to be the most relevant.

mathdotfloor

What I learned:

Math.floor(number)

This will shave off anything after a decimal point.

Math.floor(number/10)

Put this in a loop and it will cycle through digits starting in the ones place, then shift the decimal point over so the previous tens place is now the ones place, etc.

Why I needed it

The coding challenge was to add the last digit of a number, if the sum is greater than 10, drop the carried one and move on to the next digit. For example, instead of:

990 + 47 = 1037

The answer would drop all carried ones. So the answer would be:

990 + 47 = 937

So I had this long, convoluted code cycling through everything and setting digits to variables and looping through them. I got super close to the correct answer before giving up. I got to the point that I was assigning sums of digits to an array before .joining them together but it wasn’t working for the final digit if the 2 parameters (the numbers to sum) were of different lengths. I figured there had to be a better way and the solution I found used Math.floor(number/10) in a loop to cycle through it all.

test method

I just discovered the .test() method. It returns true or false based on criteria.

The reason

I found the solution for a Code Arcade challenge as:

function solution(n) {
return /0[1-9]/.test(n);
}

The problem was to check to see if an integer’s roundness could be increased. At first I didn’t understand what that meant but the conclusion I reached was that we were testing to see if you could swap a 0 in a higher place value to one of a lower place value such that it would lead to having more trailing 0’s than it does currently. I got to the point where I could check its roundness and solved a couple of the test cases but only got has high as 8/10 solved before revealing the solutions.

If my understanding is correct, putting /text/ within the /‘s will search for that pattern. .text(n) is then taking /text/ and searching for it within ‘n’. So if we wanted to modify the above function to search to also include 0’s after the first, you could put /0[0][1-9]/ and it will search both things like the number ‘103’ and ‘1003’ whereas the first function only searched for ‘103’.

EOD 1

End of the first day

So I probably should have spent my day a little more prodcutively but I’ve really wanted to get a blog configured so I’d have a place to start writing things. I tried other blogging platforms and everything seemed too… I don’t know what. Centralized? I remember the days of LiveJournal when you could randomly stumble on a likemind’s posts and it was weird and crazy and the Internet was the wild west. Now I’m happy to just have a place to talk about what I do each day/week/period of time.

Anyway, I went to the library today, planning on heading back in tomorrow as well. Applying for jobs and getting the kids some much needed social interaction. Once I got home, I started looking through plugins and themes for this Hexo blog but ended up running into issues I didn’t feel like spending hours fixing so I’m just editing the default theme.

I’m going to try to go to bed early and read a bit.

adios

Firstly

Testing

Alright, so this is my actual first post. I wanted to find a blogging site that I could use to host thoughts/info/whatever but then I got the birght idea to see if someone already made something easy to deploy on Vercel since I already deployed a couple things there. I found Hexo and an hour or so later, here we are! I’m sure there are things I still need to figure out and reconfigure but I’m ready to start writing things down now. I’m going to test a few things.

First thing’s first, tables:

Date Company Title Site URL
1/4/2023 Zenfeat React Native Mobile App Developer LinkedIn Job Link

That’s a job I applied to today.

Anyway, I don’t think I’m going to edit this blog a whole lot. It’ll just end up being text.

A bit about me

I’m a dad and husband, I lost my job a month ago and I’m looking for my first role as a software engineer. I don’t believe in social networks, especially posting my kids on them so this little blog is intended to be the entirety of my web presence. Though I haven’t been fully tested, my therapist has suggested that I check a lot of the boxes for ADHD. One of those boxes is my inability to pick a hobby and stick with it, but a few have survived my attention span and regularly give me doses of dopamine still. For one, I’m a self-taught guitarist and making music has always been part of my life. And the other hobby that’s stood the test of time, but has been waning lately is gaming. Once I started a family and lost touch with a majority of my friends, video games slowly faded from my life. I still try to play but I’ve steadily lost interest over the last few years.

Alright, I”m gonna see how this looks.
Here’s an H3:

SEE YA

Hellow Orld!

I’m writing my first post. I’m excited to see what this looks like. I was afraid I was going to have to make this whole thing myself but it seems like I can pretty easily just add to this with some markdown.