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

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.

主站蜘蛛池模板: 华蓥市| 绥化市| 县级市| 大厂| 卫辉市| 贺兰县| 黑龙江省| 米泉市| 漠河县| 共和县| 长阳| 武功县| 乐亭县| 吴旗县| 元阳县| 江孜县| 锦屏县| 乳山市| 越西县| 汶上县| 孝义市| 中阳县| 松潘县| 禹城市| 中超| 茌平县| 宜春市| 吉木乃县| 广饶县| 通山县| 曲沃县| 景泰县| 凤冈县| 阿合奇县| 青浦区| 黄陵县| 石河子市| 三河市| 沁源县| 台州市| 辉县市|