logo javascript

Javascript Course for Beginners

Instructor: Ivan Lourenço Gomes

List of Exercises # 1


1) In the /js folder, start a new .js file and name it 'ex1.js'. Make the link to this file at the bottom of this HTML page. Send the following message to the console: "This is ex1.js".

* Use this file to solve the rest of the exercises below.

2) Create variables to store your first name, last name and year of birth. In the blue box below, place the following text: "Hi, my name is _____________, I'm _____ years old and I'm learning Javascript".

This element has id="student_message". Show your message here.
* Use the current year to calculate your age.

3) Get the two numbers below and calculate the average.

101
÷
7
=
Show the result with two decimal places


4) Suppose telephone numbers with 9 digits are valid. All others are invalid. Use Javascript to test if the below numbers are valid:

                    

    var phone1 = "988866552";
    var phone2 = "99087612366";
    var phone3 = 876543123;
    
                    
                

5) Send to the console the result of the following operation: 326.


6) Consider the following variable names and inform which are invalid and why:


7) Consider the block of code below and guess what values will be shown in the console.

                    

    var quantity = "25";
    var number = 6;
    var pressure;
    var temperature = null;

    console.log(quantity += quantity); 
    console.log( (7+5) / number + 2 ); 
    console.log(pressure); 
    console.log(temperature); 
    console.log(typeof pressure); 
    console.log(typeof temperature);

                    
                    
                

8) Do the transformations to the URLs below:

www.udemy.com
show the url with https:// here

https://www.google.com
show the url without https:// here

Contents