Giter Site home page Giter Site logo

js-new-constructor-hw's Introduction

3 Constructors in JS

First Constructor

function NflPlayer (name, age){ this.team = 'colts'; this.cityLocation = 'indianapolis'; this.injuredList = false; this.name = name || '????'; this.age = age || '????';

this.injury = function(){
	this.injuredList = true;
	return name + ' is now injured!'
}

}

var andrew = new NflPlayer ('Andrew Luck', 25); var reggie = new NflPlayer ('Reggie Wayne', 34); var trent = new NflPlayer ('Trent Richardson', 24);

// For a player to get injured type name.injury()

Second Constructor

function family (FirstName){ this.address = '22 Jackson Dr.'; this.LastName = 'Huston'; this.FirstName = FirstName || '????'; this.living = true;

this.moves = function(){
	this.address = '33 Woodlane Drive';
	return FirstName + ' now lives at 33 Woodlane Drive.';
}

}

var tyler = new family ('Tyler'); var connor = new family ('Connor'); var jay = new family ('Jay'); var kate = new family ('Kate');

// For a family member to move type firstName.moves()

Second Constructor

function skydivingCrew (name){ this.name = name || '????'; this.alive = true; this.helmet = true; this.parachute = true;

this.parachuteFails = function(){
	this.alive = false;
	return name + ' is now dead!';
}

}

var billy = new skydivingCrew ('Billy'); var george = new skydivingCrew ('George'); var jason = new skydivingCrew ('Jason'); var anthony = new skydivingCrew ('Anthony');

// For a skydiver to die type name.parachuteFails()

Link

http://tyhus14.github.io/js-new-constructor-hw/

js-new-constructor-hw's People

Contributors

tyhus14 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.