# Install pipenv
pip install pipenv
# Create Venv
pipenv shell
const myLaptopObject = { | |
name : "Dell", | |
color : "black", | |
weight : 3.75, | |
working : true, | |
start : function (){ | |
//function (i.e method) to power up device goes here | |
}, | |
increaseVolume : function (){ | |
//function(i.e method) to increase volume goes here |
//Create a generator function to display some popular JS frameworks/libraries | |
function* displayFrameworks(){ | |
const javascriptFrameworks = ['Angular','React','Vue']; | |
for(let i=0;i < javascriptFrameworks.length;i++){ | |
yield javascriptFrameworks[i]; | |
} | |
} | |
const listFW = displayFrameworks(); // Generator { } |
//create a new generator function called takeOff | |
function* takeOff(){ | |
yield "Three"; | |
yield "Two"; | |
yield "One"; | |
yield "Space Craft taking off....." | |
} | |
//assign takeOff to a funtion expression named countDown | |
const countDown = takeOff(); |
class ProductCost { | |
constructor(item,quantity,price) { | |
this.item = item; | |
this.quantity = quantity; | |
this.price = price; | |
} | |
//getter | |
get cost() { | |
return this.calcCost(); | |
} |
const movie = { | |
name : "The Godfather", | |
year : 1972, | |
director: 'Francis Ford Coppola', | |
imdb_Rating: 9.2, | |
set actors(name) { | |
this.cast.push(name); | |
}, | |
cast: [], | |
get movieDetails(){ |
const movie = { | |
name : "The Godfather", | |
year : 1972, | |
director: 'Francis Ford Coppola', | |
imdb_Rating: 9.2, | |
get movieDetails(){ | |
return ` | |
The movie : '${this.name}' was directed by ${this.director} and released in the year ${this.year}. | |
It has a very high IMDB Rating of ${this.imdb_Rating} / 10. | |
` |
//define Book as an object constructor function | |
class Book { | |
constructor(name,author,price){ | |
this.name = name; | |
this.author = author; | |
this.price = price; | |
} | |
getBookCost(){ | |
return `The book ${this.name} was written by ${this.author} and costs $${this.price}`; | |
} |
//define Book as an object constructor function | |
function Book(name,author) { | |
this.name = name; | |
this.author = author; | |
} | |
//add getBookDetails method to object prototype | |
Book.prototype.getBookDetails = function (){ | |
return `The book ${this.name} was written by ${this.author}`; | |
} |