DEV Community

Adnan
Adnan

Posted on

Day 7 of #100DaysOfCode Variables and numbers

Introduction


Today marks a week since I started the #100DaysOfCode challenge, I have been able to learn a bit of HTML and CSS specifically, how to lay out different things with flexbox, which came in real handy in order for me to progress and solidify my knowledge of the pillars of the web, Today I was introduced to javascript, now I would be lying if I said that this is the first time I touched on javascript but surprisingly enough I was amazed by some basic things that i was not aware of, I'm very excited about how much this journey has to offer and how much concepts I will be able to grasp going through all of it, some things are still a bit blurry and I can't seem to grasp them or pick them up instantly, but all things aside, I really love the javascript language and it's history, and hopefully I will be able to contribute to the community in the upcoming near future, to keep this short I'm going to talk about what I did today, what I found really hard to grasp and I will include a Q&A in the last section of this article to come back to it later.


What I did today

As I mentioned yesterday, I completed the landing page project from top's curriculum with most of the sections styled using only flexbox, which was annoying at first but As soon as I got through the first couple sections the other ones felt like a breeze even though I did stutter in some of them, Obviously next up on the foundations course is another Pillar of the web, javascript or commonly known as our good old friend JS, as I said in the introduction section, I was pretty excited to start this part of the path, I very much like the javascript language, but i was amazed by how detailed and well structured the resources top's curriculum provided, don't get me wrong though, I am not a complete beginner, I did play around a bit with C and PHP and just a little small tiny bit of javascript last Year got my feet wet a little bit so to speak, but I never really stuck with anything to be a master of it nevertheless, that is solely the whole reason why I started this challenge, to wrap up what I did today, I briefly went over Variables, JS data types, operators and arithmetic operators, the difference between the three ways you could use to declare a variable, naming conventions of variables, what are the difference between operand and operators, how string concatenation work, operator precedence values, the unary operator, along with some other things, I was fascinated by how much knowledge I was lacking, I still can't grasp some types of operators, but I will keep revisiting these subjects until I fully grasp these concepts and move on to more complex things like objects and prototypes.


Q&A time

below you will find a list of Questions that are from top's curriculum that I and the experts on top believe are required concepts to kickstart your Javascript journey, if you couldn't answer, Do not worry or undervalue yourself, this is what I was talking about when I said that I was fascinated by how much knowledge I was lacking, so to keep this short here's a list of all the questions:

  1. Name the three ways to declare a variable?
  2. Which of the three variable declarations should you avoid and why?
  3. What rules should you follow when naming variables?
  4. Explain the difference between == and ===?
  5. When would you receive a NaN result?
  6. How do you increment and decrement a number?
  7. Explain the difference between prefixing and post-fixing increment/decrement operators?

Please spend some time reading through these questions, bring up your developer console and toy with js a little bit to get a grasp on how these things work, you will find the answers to this Q&A in the the last section.


Conclusion

I'm excited to carry on my learning journey and get a grasp of how javascript works, as always this has been ad until we meet again, Happy Coding!


Answers to Q&A :

  • Name the three ways to declare a variable?

answer: there is three ways to declare a variable in javascript, the old school way with the keyword var , the new keywords in town let and const. it is recommended that you always use let and const.mainly because the old keyword is only "function-scoped" and that can produce some unexpected behaviors for your variables.

  • Which of the three variable declarations should you avoid and why?

answer: it is recommended that you always use let and const.mainly because the old keyword is only "function-scoped" and that can produce some unexpected behaviors for your variables.

  • What rules should you follow when naming variables?

answer: a variable should have a clean, obvious meaning, describing the value that it stores, thus you should always spend time thinking about the right name for a variable before declaring it.

  • Explain the difference between == and ===?

answer: these are known as equality operators, it is recommend to always use the strict equality operator "===" to make your program less prone to error as it compares both the value and the data type compared to the loose equality operator that checks only if the values are the same.

  • When would you receive a NaN result?

answer: when you try to execute an illogical arithmetic operation like 'name' / 3, you cannot divide a string by a number , NOTE : NaN is sticky so any operation that has one operand as NaN will return Nan.

  • How do you increment and decrement a number?

answer: using the increment operator "++" and the decrement operator "--".

  • Explain the difference between prefixing and post-fixing increment/decrement operators?

answer: Postfix decrement operator means the expression is evaluated first using the original value of the variable and then the variable is decremented(decreased). Prefix increment operator means the variable is incremented first and then the expression is evaluated.

Top comments (0)