100日チャレンジの155日目
twitterの100日チャレンジ#タグ、#100DaysOfCode実施中です。
すでに100日超えましたが、継続。
100日チャレンジは、ぱぺまぺの中ではプログラミングに限らず継続学習のために使っています。
155日目は、
おはようございます
— ぱぺまぺ@webエンジニアを目指したい社畜 (@yudapinokio) November 8, 2019
155日目
progateのjavascript講座改変アウトプット#早起きチャレンジ#100DaysOfCode #駆け出しエンジニアと繋がりたい #javascript
学習したことの一部
practice.js
//メソッド:インスタンスの動作のようなもの
class Book {
constructor(title, subtitle, number) {
this.title = title;
this.number = number;
this.subtitle = subtitle;
}
// booktitle()メソッド追加
booktitle() {
console.log("プログラミング本");
}
// titlename()メソッド追加
titlename() {
//booktitle()メソッド呼び出し
this.booktitle();
console.log(`題名は${this.title}です`);
console.log(`サブタイトルは${this.subtitle}です`);
console.log(`巻数は${this.number}巻です`);
}
}
const book = new Book("javascript", "初心者向け", 1);
console.log(`タイトル: ${book.title}`);
console.log(`サブタイトル: ${book.subtitle}`);
console.log(`ナンバー: ${book.number}`);
// bookに対してbooktitleメソッド呼び出し
//book.booktitle();
// Bookクラスの継承: Novel
class Novel extends Book {
//getNovelbook()メソッド追加
getNovelbook() {
return this.title + this.subtitle;
}
}
const novel = new Novel('ruby', '中級者向け', 4);
novel.titlename();
// title()メソッド呼び出し
book.titlename();
//定数novelsを定義:定数novelに対してgetNovelbookメソッド呼び出し
const novels = novel.getNovelbook();
console.log(`本のタイトルは、${novels}です`);