官术网_书友最值得收藏!

Adding notes

To get started with adding notes, the first thing we'll do is create a variable called notes, and for the moment, we'll set it equal to an empty array, just as in the following, using our square brackets:

var addNote = (title, body) => {
var notes = [];
};

Now that we have the empty array, we can go ahead and make a variable called note, which is the individual note. This will represent the new note:

var addNote = (title, body) => {
var notes = [];
var note = {

}
};

On that note, we'll have the two properties: a title and a body. Now, title can be set equal to the title variable, but, as we know, inside ES6, we can simply remove it when both values are the same; so we'll add title and body as shown here:

var addNote = (title, body) => {
var notes = [];
var note = {
title,
body
};
};

Now we have the note and the notes array.

主站蜘蛛池模板: 宁阳县| 赣榆县| 凤城市| 武安市| 林口县| 北碚区| 吉林市| 道孚县| 义马市| 夏邑县| 象山县| 天津市| 康保县| 中西区| 民乐县| 错那县| 裕民县| 灯塔市| 宝清县| 武邑县| SHOW| 县级市| 包头市| 洪洞县| 新龙县| 韶山市| 曲阳县| 衡阳县| 三河市| 大田县| 甘谷县| 渭源县| 海丰县| 竹溪县| SHOW| 临西县| 兴业县| 尖扎县| 马山县| 修水县| 靖西县|