Created
November 18, 2019 16:15
-
-
Save WilyWildWilly/5eda216d0687e4252094f67ea2b0c565 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/caviciz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | |
var Book = (function () { | |
function Book(title, author, pages, description) { | |
_classCallCheck(this, Book); | |
this.title = title; | |
this.author = author; | |
this.pages = pages; | |
this.description = description; | |
this.currentPage = 1; | |
this.read = false; | |
} | |
_createClass(Book, [{ | |
key: 'readBook', | |
value: function readBook(number) { | |
console.log(typeof number); | |
console.log(number); | |
if (typeof number != "number") { | |
console.error('please type a valid number'); | |
} else if (number <= 0) { | |
console.error('please type a valid number'); | |
} else if (number > this.pages) { | |
console.error('please type a valid number'); | |
} else { | |
this.currentPage = number; | |
console.log(this.currentPage); | |
} | |
} | |
}]); | |
return Book; | |
})(); | |
var firstBook = new Book("La Profezia di Celestino", "James Redfield", 355, "Un libro new age"); | |
var secondBook = new Book("la Photo", "Tom Ang", 228, "un libro sulla foto"); | |
var thirdBook = new Book("Pure Colère", "Camille Lepage", 402, "L'ultimo libro di Camille Lepage"); | |
var fourthBook = new Book("la Photo Documentaire", "Stephanie Calabrese Roberts", 480, "un trattato sulla foto documentaristica"); | |
var bookList = [firstBook, secondBook, thirdBook, fourthBook]; | |
firstBook.readBook(350); | |
console.log(firstBook.currentPage); | |
console.log(firstBook.read); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">class Book { | |
constructor(title, author, pages, description) { | |
this.title = title; | |
this.author = author; | |
this.pages = pages; | |
this.description = description; | |
this.currentPage = 1; | |
this.read = false; | |
} | |
readBook(number) { | |
console.log(typeof(number)); | |
console.log(number); | |
if (typeof(number) != "number") { | |
console.error('please type a valid number'); | |
} | |
else if (number <= 0) { | |
console.error('please type a valid number'); | |
} | |
else if (number > this.pages) { | |
console.error('please type a valid number'); | |
} | |
else { | |
this.currentPage = number; | |
console.log(this.currentPage); | |
} | |
} | |
} | |
let firstBook = new Book ("La Profezia di Celestino", "James Redfield", 355, "Un libro new age"); | |
let secondBook = new Book ("la Photo", "Tom Ang", 228, "un libro sulla foto"); | |
let thirdBook = new Book ("Pure Colère", "Camille Lepage", 402, "L'ultimo libro di Camille Lepage"); | |
let fourthBook = new Book ("la Photo Documentaire", "Stephanie Calabrese Roberts", 480, "un trattato sulla foto documentaristica"); | |
let bookList = [firstBook, secondBook, thirdBook, fourthBook]; | |
firstBook.readBook(350) | |
console.log(firstBook.currentPage); | |
console.log(firstBook.read)</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | |
var Book = (function () { | |
function Book(title, author, pages, description) { | |
_classCallCheck(this, Book); | |
this.title = title; | |
this.author = author; | |
this.pages = pages; | |
this.description = description; | |
this.currentPage = 1; | |
this.read = false; | |
} | |
_createClass(Book, [{ | |
key: 'readBook', | |
value: function readBook(number) { | |
console.log(typeof number); | |
console.log(number); | |
if (typeof number != "number") { | |
console.error('please type a valid number'); | |
} else if (number <= 0) { | |
console.error('please type a valid number'); | |
} else if (number > this.pages) { | |
console.error('please type a valid number'); | |
} else { | |
this.currentPage = number; | |
console.log(this.currentPage); | |
} | |
} | |
}]); | |
return Book; | |
})(); | |
var firstBook = new Book("La Profezia di Celestino", "James Redfield", 355, "Un libro new age"); | |
var secondBook = new Book("la Photo", "Tom Ang", 228, "un libro sulla foto"); | |
var thirdBook = new Book("Pure Colère", "Camille Lepage", 402, "L'ultimo libro di Camille Lepage"); | |
var fourthBook = new Book("la Photo Documentaire", "Stephanie Calabrese Roberts", 480, "un trattato sulla foto documentaristica"); | |
var bookList = [firstBook, secondBook, thirdBook, fourthBook]; | |
firstBook.readBook(350); | |
console.log(firstBook.currentPage); | |
console.log(firstBook.read); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment