Skip to main content

Posts

Showing posts from October, 2018

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...

JavaScript Arrays

[5/100] Today was spent primarily on going over arrays, their methods and playing around in the console seeing what I can do with it. I can honestly say that after spending some time on it I understand much better the process of creating an array from a string and manipulating one with different methods. The ones I used where .pop/.push, .shift/unshift, .slice, indexOf and .join. The MDN web docs  were a crucial resource when I was exploring their possibilities (I only scratched the surface though) and I definitely deepened my understanding of each one of them. The biggest help with JS I got from the Bootcamp has been so far Colt's use of Chrome's console to test the code. I didn't think about it before and writing everything in Sublime and then testing, having it not working and trying to figure out what's happening and why was infuriating. With the use of console I can immediately test every single line of code, check what it does and make sure it works properly. ...

Modular CSS

[4/100] Today was spent more on reading web development articles and finishing the function classes on Udemy, that writing any code itself (total coding time 11 minutes!). For a few days I have been planning to read an article on modular CSS. It stresses the importance of using BEM (block, element, module), OOCSS (object oriented CSS) and SMACCS (scalable & modular architecture for CSS) methodologies to write an easy to maintain and reusable code. I think it was two years ago or so when I read for the first time a documentation on BEM. I never got to use it since I was never involved in a big project where this would come in handy and also I never decided that I should use it for any of my projects. Nevertheless, I realize that even on a smaller scale this approach might be convenient. Without actually using it, I still have been trying to utilize the best practices when writing my code which are documenting, commenting, organizing by hierarchy and using comprehensive class...

JavaScript Functions

[3/100] Today was busy and I had an only an hour or so in the evening to sit down and continue JS overview. I did additional small work on Wix but cannot really call it coding... I gave myself a promise and even if it means giving it only 5 minutes I am gonna write a line of code everyday. I am continuing Colt's bootcamp on Udemy. We have been going over JS functions and their structure which is: function function_name ( argument /empty) { doSomething; } There are also two ways of defining a function: Function declaration  function capitalize(str) {   return str.charAt(0). toUpperCase () + str. slice (1); } Function expression var capitalize = function (str) {   return str. charA t(0). toUpperCase () + str. slice (1); } I am familiar with the concept and the exercises went pretty smoothly, however I had a tough time with writing a function that was supposed to return a factorial of a number. I could not figure out how it ...

Basic JavaScript concepts

[2/100] I am continuing the review of basic JS concepts and functions with Colt Steele on Udemy.  At the moment I am playing around with WHILE and FOR LOOPS. It is all pretty logical to me and I remember a bunch of it. One thing that I always struggle with however is memorizing the structure of each function and names of methods and properties as well as what they do. I think the problem is that I don't write my own JS code on a general basis but rather tweak snippets and plugins I find. I try to solve weekly code challenges on Code Wars  as a way to actually use some of the knowledge I have and learn something new. It is fun and on more than one occasion frustrating but it still feels like not enough to actually remember what exactly I am doing. Maybe there is inherently a fault in the wiring of my brain or simply I just need to find a way to help myself with the process. I would love to, at some point, go in-depth into MDN web docs  and explore this great resour...

Let's begin

[1/100] For a while I have been playing with an idea to challenge myself with coding everyday for 100 days. I feel like it will be a good thing to set myself such goal, push my skills further and come out as a better and much more experienced developer at the end of it. In meantime, I am also hoping to improve my writing skills and maybe develop this blog into something bigger that will help me brand my name online. I decided to quickly set up a blogger to not waste any time (or procrastinate) starting this challenge. I am not sure yet about the structure and format of each post. For starters, I will simply sum up each day with what I did and learnt. I will research how others do it and with time I am sure I will see and discover what works for me the best and probably I will find more creativity in it. I think somewhere along the road I might also build something more custom or advanced. We shall see. //To sum up day 1 Today I finished Udemy course on Bootstrap 4 with Brad Tra...