Domain Modeling :neutral_face:

Define a constructor and initialize properties


var EpicFailVideo = function(epicRating, hasAnimals) { this.epicRating = epicRating; this.hasAnimals = hasAnimals; }

var parkourFail = new EpicFailVideo(7, false); var corgiFail = new EpicFailVideo(4, true);

console.log(parkourFail);


  1. The new keyword instantiates an object.
  2. The constructor function initializes properties inside that object using the this variable.
  3. The object is stored in a variable for later use.

Generate random numbers

var EpicFailVideo = function(epicRating, hasAnimals) { this.epicRating = epicRating; this.hasAnimals = hasAnimals; }

EpicFailVideo.prototype.generateRandom = function(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }

var parkourFail = new EpicFailVideo(7, false); var corgiFail = new EpicFailVideo(4, true);

Tips to follow when building your own domain models.

  1. Model its attributes with a constructor function that defines and initializes properties.
  2. Model its behaviors with small methods that focus on doing one job well.
  3. Create instances using the new keyword followed by a call to a constructor function.
  4. Store the newly created object in a variable so you can access its properties and methods from outside.
  5. Use the this variable within methods so you can access the object’s properties and methods from inside.

Tables

Basic Table Structure

  1. <table> : The <table> element is used to create a table. The contents of the table are written out row by row.
  2. <tr> : You indicate the start of each row using the opening <tr> tag. It is followed by one or more <td> elements. At the end of the row you use a closing </tr> tag.
  3. <td> : Each cell of a table is represented using a <td> element.

Long Tables

There are three elements that help distinguish between the main content of the table and the first and last rows

  1. <thead>: The headings of the table should sit inside the <thead> element.
  2. <tbody> : The body should sit inside the <tbody> element.
  3. <tfoot>: The footer belongs inside the <tfoot> element

Border & Background

Functions, Methods, Objects

ADDING AND REMOVING PROPERTIES

GLOBAL OBJECTS NUMBER OBJECT

MATH OBJECT TO CREATE RANDOM NUMBERS

var randomNum = Math.floor((Math.random() * 10) + l);
var el = document.getElementByid('info');
el .innerHTML = '<h2>random number</h2><p>' + randomNum + 1</p>'; 

More About Functions, Methods,Objects


Table Of Content