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

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.

主站蜘蛛池模板: 广汉市| 长丰县| 肃宁县| 昌平区| 永春县| 尼玛县| 金山区| 北流市| 清水河县| 遂川县| 荥阳市| 渝中区| 密云县| 武安市| 高邑县| 大同县| 海兴县| 丰台区| 新巴尔虎左旗| 定州市| 乐亭县| 永仁县| 龙州县| 唐河县| 山东省| 瑞昌市| 东海县| 汾阳市| 鹤庆县| 炎陵县| 明水县| 宜兰市| 崇阳县| 抚顺市| 曲沃县| 思茅市| 乌兰察布市| 克拉玛依市| 茶陵县| 陵水| 南靖县|