001. Solving 30-Days-Of-JavaScript challenge questions.

Photo by Clark Tibbs on Unsplash

001. Solving 30-Days-Of-JavaScript challenge questions.

If you want to take your JavaScript skills to the next level you should follow along this series that I'll be doing on this blog. The author Asabeneh, organized the series in chronological order of hardness. The questions get complex as we move on. I have this idea of solving questions in the 30-days-JavaScript Challenge byAsabeneh. There are hundreds of questions in his GitHub. I will be doing them in multiple articles.

Let's start the series by solving day 1 of the challenge.

Note: If you are and advanced JavaScript programmer, this first article might not be that helpful. You can read and help me by providing the different ways of solving some of the questions.

1. Write a single line comment which says, comments can make code readable

To write a single line comment we start with two forward slashes.

Solution: Question 1.PNG

2. Write another single comment which says, Welcome to 30DaysOfJavaScript.

Solution:

2.PNG

3. Write a multi-line comment which says, comments can make code readable, easy to reuse and informative

We write multi-line comments by enclosing them with /**/. i.e.

/*

Line 1

line 2

Line 3...

*/

Solution:

3.PNG

4. Create a variable.js file and declare variables and assign string, boolean, undefined and null data types

Here I used Visual studio code.

First created a file called variable.js.

Note that we can not use const keyword to declare an undefined variable.

Solution:

Capture 4.PNG

5. Create datatypes.js file and use the JavaScript typeof operator to check different data types. Check the data type of each variable

Now let us check the data types of the varaibles we declared in question 4.

Solution: 5.1.PNG

6. Declare four variables without assigning values.

Pretty simple, right?

Remember, we can only use the let or var keywords to declare undefined variables. Note that a const value can never be undefined. That is why we have a red underline where we used const.

Solution:

let

6.PNG

var

6.1.PNG

const

6.2.PNG

7. Declare four variables with assigned values

Here we can use any of the three keywords to set up our variables.

Solution:

let

7.PNG

var

7.1.PNG

const

7.2.PNG

8. Declare variables to store your first name, last name, marital status, country and age in multiple lines.

As a convention, I will use the const keyword to store my data since it won't change anytime soon except for the age and marital status.

However, most people prefer using the const keyword irregardless of whether the values will change or not. This is to avoid overwriting the values in future.

Solution:

8.PNG

9. Declare variables to store your first name, last name, marital status, country and age in a single line

Solution:

9.PNG

10. Declare two variables myAge and yourAge and assign them initial values and log to the browser console.

Solution:

10.PNG

Thanks for your attention. Next we will tackle Day 2 questions.

Watch out !! for complex questions as we proceed with the challenge.

Disclaimer: I don't own any part of this article. I only shared solutions.