Skip to main content

Command Palette

Search for a command to run...

[DAY 18-20] I Built A Game & A Calorie Counter In Javascript

Published
2 min read
T

Hey, I'm Thomas, a civil engineer that just discovered coding.

On this blog, I document my learning journey until I become a full-stack developer.

If you love documenting progress and coding, consider following! See you in the next blog!

Hi everyone! Welcome back to my blog where I document the things I learned in web development. I do this because it helps retain the information and concepts as it is some sort of an active recall.

On days 18-20, I built a text-based role-playing game and a calorie counter to learn basic Javascript concepts and form validation.

10 things I learned:

  1. JavaScript interacts with HTML using the syntax document.querySelector() and document.getElementById().

  2. Initialize buttons with object properties such as .onclick (e.g. button.onclick = myFunction)

  3. The use of arrays [] and objects {} in building my role playing game.

    1. Utilizing key-value pairs within objects.
  4. Refactoring such as using compound assignments for clean code.

  5. Adding newlines in Javascript using \n.

  6. Block scoping where I put a variable inside a code to only be accessible inside that block.

  7. Regular expressions to avoid non-alphanumeric characters in building my calorie counter.

  8. More method calls like .replace(), .Number(), .toLowerCase(),.addEventListener(), etc.

  9. Template literal syntax (e.g. `string string string ${variable}` ), this is a great alternative to concatenations.

  10. To use ternary operators (e.g. const variableName = condition ? ‘if true statement’ : ‘if false statement’;)

Comparing my progress when I was learning HTML and CSS, previously, I was able to build 1-2 projects per day. But now in Javascript, I can only build 1 or complete half a project per day.

The reason why it takes longer than before is because for me, Javascript is harder to digest than HTML and CSS. Also, I’m taking more time to understand its concepts and learn the purpose of every syntax that freecodecamp is teaching me. Additionally, I take the time to understand the why behind every line of code that I write.

Overall, I'm having fun with my coding progress and day by day I feel the improvement and it helps a lot in maintaining momentum to keep being consistent in learning.

That’s all for now, thank you for reading. I’ll see you all next blog!

B

TROPICAL DELIGHT RECOVERY IS THE ONLY VERIFIED LICENSE COMPANY.

Are you looking for a way to recover cryptocurrency you misplaced or had stolen? I'm pleased to inform that Tropical Delight Recovery Hacker has resolved the issue that nearly caused my house to fall since I spent the monies my spouse wanted to utilise to start a business. I lost $1.4 million in bitcoin and etherium to these scammers. They excel at what they do and are the leading certified cryptocurrency recovery company. They can be reached instantly at: @ tropicaldelightrecoveryhacker on Telegram and @ tropicaldelightrecoveryhacker.93 on Signal. The email address is TropicalDelightRecoveryHacker @ out look .com.

E

Hi, l've got some exciting news for you, l can teach you how you can turn your $150 into a whopping $4,600 in just 2 hours! Without interrupting your daily activities or sending money to anyone TEXT ME IF YOU ARE INTERESTED FOR MORE INFORMATION: 👇 WhatsApp No:+1 (209)-207-5967‬ Text No:+1 (209)-207-5967

Q
Qyrus AI2y ago

Great job taking the time to learn JavaScript and all its innerworkings. Learning code isn't easy! Excited to see what else is to come!

2
T

Appreciate the comment! Thank you for the follow and will for sure post more updates in my coding journey :)

More from this blog

Thomas Learns Coding

42 posts

Hi there! I'm Thomas, I document my learning journey until I become a full-stack developer.

If you love progress vids and coding, consider following! See you in the next blog! 😄