You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30-Days-Of-JavaScript/Exercise-Solutions/days/01_day_introdiction.md

2.3 KiB

Day 1 - Introdiction

Exercise:Solutions

Home | Day 2 >>

Exercise Solutions

Exercise Level 1

  1. Write a single line comment which says, comments can make code readable
// comments can make code readable
  1. Write another single comment which says, Welcome to 30DaysOfJavaScript
//Welcome to 30DaysOfJavaScript
  1. Write a multiline comment which says, comments can make code readable, easy to reuse and informative
/*        comments can make code readable,
           easy to reuse and informative  */
  1. Create a variable.js file and declare variables and assign string, boolean, undefined and null data types
//variable.js
let string = 'nevzat'
let number = 25
let boolean = true
let nulll = null
let any;     //undefined

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

//variable.js

let string = 'nevzat'
let number = 25
let boolean = true
let nulll = null
let any; 

console.log(typeof (string) )  //String
console.log(typeof (number))   //Number
console.log(typeof (boolean))  //Boolean
console.log(typeof (nulll))    //Object
console.log(typeof (any))      //Undefined
  1. Declare four variables without assigning values
    let variable1;
    let variable2;
    var variable3;
    let variable4;
  1. Declare four variables with assigned values
variable1 = "nevzat"
variable2 = "ATALAY"
variable3 =  true;
variable4 = 25;
  1. Declare variables to store your first name, last name, marital status, country and age in multiple lines
let firstName = "nevzat"
let lastName = "atalay"
let old = 25
let isMarried = true
  1. Declare variables to store your first name, last name, marital status, country and age in a single line
let name = "nevzat",surName="atalay",age = 25, married = true
  1. Declare two variables myAge and yourAge and assign them initial values and log to the browser console.
let myAge= 25
let yourAge = 22

console.log("I am " + " " +  myAge + " " + "years old.") // I am 25 years old.
console.log("You are" + " " +  yourAge + " " +  "years old.") // You are 22 years old.

Home | Day 2 >>