⭐️Tech Trivia Tues⭐️

ANSWER: '55'

This is because of how type conversion and the .join() method work on JavaScript.

I'll walk you through the code on the thread below 👇🧵
Type conversion in JavaScript can be a little bit weird.

If do math with a number and a non-numeric value, JS will try to convert the non-numeric value into a number.

In this case, when `true` is converted to a number value, it returns the number 1.
Check out the code below:

The following expression will return 5 because 1 * 5
Now, let's take a look at [,,,]

This is an empty array with a length of 3.

Since it's an empty array, it will return `undefined` 3 times.
We're using the .join() method to concatenate (true * 5) with array [,,,]

The .join() method converts all the elements of an array to strings and concatenates them.

In this case, when `undefined` is converted to a string, it converts into empty strings.
Also, when we pass an argument to the .join() method, it uses that argument as a separator.

In other words, JS uses string '5' to separate all three empty elements.

Take a look at the code below:

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Yuri 🇰🇷

Yuri 🇰🇷 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @codingyuri

12 Aug
10 most common Mac Terminal commands (in my experience)

A thread 🧵
1⃣ pwd

Use the `pwd` command to find out your current location in the filesystem/name of the folder currently open in your terminal window.

After executing `pwd` command, terminal tells us that we're in `Yuri` directory inside of `Users` at root Image
2⃣ ls

The `ls` command is used to list all the folders/files under the location specified, or if not specified, under the current location.

Here, we're listing all the directories/files inside `~` Image
Read 15 tweets
2 Aug
WTF is the deal with scope?😤

Scope can be very confusing when you're just starting out, especially with variable declarations!! So, I think that it's an important concept to know early on!😆

In this thread, we'll review scopes & its weird parts😉

A thread 🧵
1⃣WTF is scope?

Scope: visibility of the variable

Basically, scope refers to how your program can see or access a variable. Normally, when you declare a variable, It has global scope, meaning that it's accessible anywhere on your code.
2⃣ Variable global scope

Variables with global scope are declared OUTSIDE a function or a loop. If a variable's scope is global, it can be accessed anywhere in the code, even inside other functions or loops.
Read 12 tweets
10 Jul
Open Source is a great way to improve your reputation as a dev, and practice your coding skills by reading other people's code and receiving feedback!
It's also a great way to give back to the community!

How to contribute?
A thread 🧵
#Coding #WomenWhoCode #webdevelopment
1⃣ Find a project in GitHub you're interested in!

Usually this is the first step. Finding a project that interests you will motivate and help you become an active contributor. But as a #CodeNewbie, or your first time contributing, your first approach might be a bit different👇
If you're a beginner, the difficulty of the issues might put you off from choosing a project you like (happened to me!). Don't worry about it, beginners can contribute to open source and add contributing experience to their resumes as well. 👇
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(