JavaScript Fundamentals Part 2

Last year, I continued studying on Fundamentals of Javascript in the Odin Project Web Development 101. I decided to start off the New Year by doing a review of what I had studied a month ago.

I did the first JavaScript “Test Yourself” questions in this blog post.

These are the second JavaScript “test yourself” questions here and my answers below.

  • What are the seven data types of javascript?
  1. Number
  2. String
  3. Boolean
  4. Null
  5. Undefined
  6. Object
  7. Symbol
  • Which data type is NOT primitive?

Object.
This is because objects store collections of data and more complex entities.
Whereas, numbers, strings, booleans, null, undefined, and symbol are represented directly. Also, those data types cannot be changed (although, the variables they may be stored in can change).

  • What is the difference between single, double, and backtick quotes for strings?

Single and double quotes are the same. But they need to be used consistently, not mixed – ‘Hi’ or “Hi”
not “Hi’

Backtick quotes are extended functionality quotes. They allow us to embed variables and expressions into a string using  backticks:
stringtext ${variable} stringtext `

  • Which type of quote lets you embed variables/expressions into a string?

Backticks.

  • How do you embed variables/expressions into a string?

Using the dollar sign and { } brackets together.
The variable or expression would be written within the curly brackets.

  • How do you escape characters in a string?

​​​​​You can escape characters, like a  single, double, or backtick quote with a backslash before them \’ \” \`

  • What is the difference between slice/substring/substr?

These are three ways to extract part of a string.
The parameters are different in each:

  1. slice(start, end)
  2. substring(start, end)
  3. substr(start, length)

Slice extracts part of a string and returns the extracted part in a new sting.
Substring is similar to slice. Substr is different because you choose the length of the string you want to get, rather than the end point of the original string.

  • What are methods?

A method is a bit of functionality that is built into the language. They are properties which contain a function. So, slice(), substring(), and substr() are methods.
Also, indexOf() and search() are methods.

  • What are the three logical operators and what do they stand for?

&& AND

|| OR

! NOT

  • What are the comparison operators?

> greater than
< less than
>= greater than or equals
<= less than or equals
== equality check
!= not equals

  • What is nesting?

When we put something inside something else.
In JavaScript, we can nest if statements within each other. For example,
if (condition) {
xyz } else if (condition) {
zyx } else {
abc }

  • What are truthy and falsy values?

A value that evaluates as true in a Boolean context is truthy.
A value that evaluates as false in a Boolean context is falsy.

  • What are the falsy values in Javascript?
  1. false
  2. undefined
  3. null
  4. 0
  5. NaN
  • What is the syntax for an if/else if/else conditional?

if (condition) {
xyz } else if (condition) {
zyx } else {
abc }

  • What is the syntax for a switch statement?

switch (expression) {
case choice 1:
run this code
break;
case choice 2:
run this code
break;
default:
actually, just run this code
}

  • What is the syntax for a ternary operator?

(condition) ? run this code : run this code instead;

  • What is the relationship between null and undefined?

Null is a value. It means “nothing, empty, no value”.
Whereas, Undefined means there is a variable but “value has not been assigned”.

If you test equality:
null == undefined would be true
null === undefined would be false

This is because with strict equality they need to be the same type to return true. Null is an object, but undefined is a type of value itself.

  • What are conditionals?

Conditionals are statements which execute a block of code is certain conditions are true.
Conditional statements include:

  1. if
  2. else
  3. else if
  4. switch

 

Advertisements

Git and GitHub

I studied a bit about Git and GitHub recently by following the track on Odin and watching Le Wagon’s Git and GitHub movie.

Yesterday, I created a repository on GitHub.

Then I cloned it on my local machine.

I used the command line to start tracking that repository with Git on my machine, then I created new files in the local repository.

I made a README.md file. Then I added it to the staging area. Then committed the file with a short message about what I did.

I repeated this process with a hello-world.txt file.

Then I pushed my changes to GitHub.

You can see the repository here.

It was a very simple thing but actually implementing what I had learned about Git, GitHub and the command line and seeing it come up on GitHub felt like a proud moment for me last night.

Odin Project – Community

I was working through the Odin Project course.

The first course is Web Development 101.
There is a lesson called “Your First Rails Application”.

After learning about the command line, you learn how to configure Git and GitHub.

Then you follow the steps to create a Ruby on Rails web application.
Which you can see here:
https://github.com/rebeccode/OdinSetup

After my initial commit after following all of the instructions – it didn’t work.

I couldn’t figure out why and I wasn’t sure what to do.

I went to the Odin Project Gitter – which is like a community forum and chat for people interested in the Odin project.

I posted my issue:

odinprojectstuck.png

I wasn’t expecting any response – but actually two or three people tried to help me.

One person helped to solve the issue and once I’d made the change he suggested it the code compiled and it worked!

odinprojectunstuck.png

Within 20 minutes of my posting my query on the Gitter chatroom I had managed to fix everything!

I felt this sense of appreciation and pride – for the first time I felt like I’d become part of a community here.

My first rails app can be found here.
It is the code provided by the Odin Project for a kind of car naming list. You can add new cars, edit ones already in the list, and erase them from the list.

I don’t really understand all of what I did there because I was just following instructions. As I progress through Odin it’s going to go back and teach topics in more detail.

Next, I’m going to be learning more in depth about Git and Github.

Coding summer school for kids in Koenji, Tokyo

I saw a computer school in Koenji, Tokyo which is advertising for a summer school for children.

programmingflyerset.png
Image © Rebeccode

The flyer is advertising a course using a program like Scratch to teach block based programming to grade 1-4 elementary school  students.

It is a three hour course over two days (for a total of 6 hours) for 9,800 yen.
That’s about the same price as two day tickets for children to Tokyo Disneyland – whereas investing in their future and having them try out coding could be seen as a valuable experience.

The flyer also mentioned that being an IT engineer or programmer was the number one job that Japanese boys dreamed of becoming in 2017 – at 24% of children surveyed.

Unfortunately this course has already finished as the summer vacation period is coming to an end.

Accenture Digital Skills Free Courses

FutureLearn (a mass open online course site) is partnered with Accenture and they are providing a bunch of free accredited courses with no deadline (i.e. you get a certificate at the end that you can show with a transcript of what you studied and you can take as long as you like to do them).

Their digital skills courses include:

  • User Experience (UX)
  • Retail
  • Digital Marketing
  • Web Analytics
  • Grow your career
  • Social Media
  • Mobile

Each course takes 2-3 weeks to complete at 1-2 hours per week.

You can look at the details on their website here.

I’m particularly interested in the UX course (that’s how I found this series of courses).

I signed up for them all and I’ll update here about my progress with them and a review at the end.

My first job rejection!

It’s Monday and I was in my office today. I’ve been using my lunch breaks for the past week at work to study programming.

Today I was still working on the “Learn the Command Line” course on Codecademy – I’m 53% through now.

Today I learned about redirecting the input from commands.
This allows you to combine actions – for example, sorting a file into alphabetical order, then erasing duplicate entries in the list, then outputting it to a new file.

I also got my first ever rejection email from an IT related job (which is not a surprise, considering I have only been researching the IT field for about 2 months).

Printscreen of email
Image © Rebeccode

I never thought I’d feel happy about a rejection – but I feel like it is a good thing for me.

I can see now I’m not good enough.

Each day I’m learning new things and the effort I put in will change my life.

Still learning how the internet works

Recommended as extra reading, I picked up a copy of this book and I’ve been reading it on the train to and from work.

It is one guy telling the story of his travels around the world to really figure out what the internet is, and where it is.

So far, the idea of how we see the internet as something mystical.

It reminded me of the Cartesian soul/body dualism. The philosopher Rene Descartes had the theory that the body is something physical but the soul (or mind) is something immaterial and somehow interacting with the body.

In a way, we feel like this about the internet – we know the computers and devices are physical but they are somehow connected to this immaterial “internet” thing which seems beyond our understanding.

So, in this book the author is actually finding and examining the wires or “tubes” that are the physical basis of the internet. Similarly to how we now look at the brain to see the “mind”.

I’ve only been reading it for two days so far but I’m enjoying it.