Exercise – Variables & Data Types

by Desiree Guercio

HTML

<script>

var person = {
Name:'Desiree',


};
var Yearborn = 1985,
var CurrentYear = 2015,
var Greetings= 'My Name Is';
var myage='and my age is' ;
Age = CurrentYear - Yearborn;
Presentation = (Greetings + ' ' + Name + ' ' + myage + ' ' + Age);
    
</script>

CSS

var person = {
Name:'desiree',
Yearborn:1985,
CurrentYear:2015,

};

var Greetings= 'My Name Is';
var myage='and my age is' ;
Age = CurrentYear - Yearborn;
Presentation = (Greetings + ' ' + person.Name + ' ' + myage + ' ' + Age);

JavaScript

/**
 * Exercise:
 * Get to know your data types and variables
 *
 * Follow the directions below but feel free to experiment and veer off course.
 * Work in the console directly OR use "console.log()" to output to the console from the script.
 */

// 1)
// Declare 2 to 5 variables (name them as you like)
// Make at least one string, one number and one boolean. 
// Log the typeof each to the console
var Name = 'desiree';
var Yearborn = 1975;
var CurrentYear = 2015;
var Greetings ='My Name Is';
var myage = 'and my age is' ;

// 2)
// Declare a new variable that stores the result of a mathematical expression
// You can add/multiply/divide/modulo any set of numbers 
// Log the result to the console

var Age = CurrentYear - Yearborn;


// 3)
// Combine at least three strings together
// Log the result to the console

var Presentation = (Greetings + ' ' + Name + ' ' + myage + ' ' + Age);

// 4)
// Create an array with at least 5 values stored inside
// Log the result to the console

// 5)
// Use Array.prototype.concat to add another array to your original array
//  var arr3 = arr1.concat(arr2);
// Log the result to the console

// 6) 
// Create an object literal that represents a person (perhaps you!)
// Define several properties within the object (name, hairColor, age, etc..)
// Define a property that stores an array ("siblings" or "favoriteColors")
// Log the object to the console
// Then Log ONLY the "name" property to the console
// Then Change the "name" property to something else, then log the object to the console

// 7) Bonus
// Add a function (method) to the previous object you created to allow it to "speak" to the console. The function should expect a string argument and output "<object.name> said: <string>" to the console.