Skip to main content

Posts

Compare two arrays

Tutorial on comparing two arrays Let's talk about comparing two array against each other and returning values that they have in common or values that they don't. A bit of back story -- writing a function that will return common values was pretty easy for me to come up with however, returning unique values gave me some trouble and I spent quite a lot of time researching it. Eventually I found this neat  solution  and honestly I am not completely sure if I would get to it myself since I haven't been working enough with objects or this type of statement. Therefore, I will be going back to basics and I am planning to go through the Statements  section on MDN. The solutions  By using  For In...  statement we can solve both problems and I am still trying to figure out if it's possible to apply  For Loop in the unique values function. Return common values I used here a  For Loop on both vowels and str  arrays (string becomes an arr...

Create an array from a string of numbers

Tutorial on creating an array from a string of numbers. Lets say we want to create an array from a string of numbers ("1 9 3 4 -5") . We could use two things to do so: Array.from() var strNum = ("1 9 3 4 -5"); var arrNum = Array.from(strNum); The idea here is good and it should work but we end up with an array that looks like this: arrNum = ["1", " ", "9", " ", "3", " ", "4", " ", "-", "5"]; It is not ideal, since we have an array containing spaces and negative numbers lost their minus sign. split() Let's see how we can do that by using the split() method: var strNum = ("1 9 3 4 -5"); var arrNum = strNum.split(""); Once again we will end up with an array separating all the spaces and minus signs: arrNum = ["1", " ", "9", " ", "3", " ", "4...

Empty input in a function

Tutorial on an empty input in a function. I was doing this challenge on Code Wars where I had to "Return null if param is null or array is empty." This caused me some trouble and took me a while to figure out how to write a condition for an empty input in a function. This is something I came up with and it worked for me: It was interesting for me to find a way to write it this way where basically it test if the value has no length which seem pretty obvious right now.

Numbers in JS

Tutorial on numbers. Doing bunch of Code Wars challenges where I had to verify if an argument is an number made me discover various ways it can be done. Below I will describe some of the things I used. typeof operator Basically we compare an argument to a value called  'number' . It will return for  true decimals, negative numbers, math operations inside a parenthesis, infinity, NaN etc.. MDN documents going more in depth. typeof 10 === 'number'; typeof 10.2 === 'number'; typeof (5+10) === 'number'; Number.isInteger() We are passing a value inside the parenthesis and receive  true or  false  depending if the valueis an integer. It will return false for decimals and math operations. MDN lists more cases. Number.isInteger(10) === true; Number.isInteger(10.2) === false; NaN There are a few ways this can be used:  Number.isNaN();  method where we check if passed value is not a number. We can add   !  sign...

Progress

[11-24/100] Days have been passing quickly. I neglected this blog a bit since not much interesting has been happening and writing posts takes a bit of time. Without having any written proof, I can attest that I am still going strong with the 100 days of coding challenge and haven been pretty productive during my absent days on here. I haven been mainly focusing on training my skills and newly gained knowledge on Code Wars and doing the Bootcamp classes. Right now, I am finishing Advanced DOM Manipulation and it has been going great. I did this type of work before with jQuery and didn't know anything about JS approach to it. So far it has been pretty logical and clear to me how to use it. Next step will be brushing off my elementary knowledge of jQuery itself. In general, things are going at a slow pace since with every concept I do my research, go over the MDN docs and articles, try to practice it on CW (Code Wars) and don't stop till I feel confident I got a good grasp o...

Code Wars

[8-9-10/100] The last few days I have been working on solving various JS assignments from Colt's Bootcamp - finishing the to-do list and a few others he gave, as well as challenging myself to Code Wars  'katas' (a name they use for their coding tests). It's been really helpful in terms of diving deeper into arrays, methods and writing my on functions. I am slowly starting to feel a difference in my JS proficiency. When I first registered on Code Wars even the easiest katas were overwhelming and difficult for me. I cannot say I am 'fluent' now but I definitely understand better what I am being asked to do, how to research and solve errors when I get them. I am still only tackling the low level katas at the moment but I think soon I will be able to attempt the higher level ones. It's fun to see this progress knowing that at some point I wanted to completely give up on JS thinking I will never get it. I have two articles on my reading list right now: one a...

Challenge of the challenge

[6-7/100] Looks like so far the first major challenge in this challenge has been the weekend. We have had a family over and for majority of those two days we were out and about and getting some nice time together. Therefore, it didn't go as planned and I didn't finish the arrays and have been stuck on one building a to-do list exercise. I made an honest effort to make time for it but I guess sometimes you just need to accept that you can't have control over how your day goes and some things will take priority. Either way, a fresh new week is starting and I will have plenty of time to work and be productive. I will try and do my best to make up for the lost couple of days. I will probably mostly focus my energy on finishing a project of rebuilding a website for a dentist office. The perfectionist in me wishes to have perfect 100 days of this challenge but I need to remind myself that it's not reasonable. The most important thing is to keep moving forward and not gi...