-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayground.js
86 lines (65 loc) · 1.8 KB
/
playground.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
////////////////////////////////////////////////////////////////////////////////
// const fs = require('fs');
// let notes = {
// title: "Note title",
// body: "Note body",
// }
// let notesJSON = JSON.stringify(notes);
// // fs.writeFile('notes.txt', notesJSON, (err) => console.log(err))
// fs.writeFileSync('notes.txt', notesJSON);
// const buffer = fs.readFileSync('notes.txt');
// const data = JSON.parse(buffer);
// data.title = 'changed title';
// data.body = 'changed body';
// notesJSON = JSON.stringify(data);
// fs.writeFileSync('notes.txt', notesJSON);
////////////////////////////////////////////////////////////////////////////////
// const o = {
// name: 'name',
// obj: {
// name: "Party",
// list: ['alex', 'tom', 'jen'],
// parent: this.name,
// func() {
// console.log(this.parent);
// }
// }
// }
// o.obj.func();
////////////////////////////////////////////////////////////////////////////////
//
// Goal: Create method to get incomplete tasks
//
// 1. Define getTasksToDo method
// 2. Use filter to to return just the incompleted tasks (arrow function)
// 3. Test your work by running the script
// const tasks = {
// tasks: [{
// text: 'Grocery shopping',
// completed: true
// }, {
// text: 'Clean yard',
// completed: false
// }, {
// text: 'Film course',
// completed: false
// }],
// getTasksToDo() {
// return this.tasks.filter(task => !task.completed)
// }
// }
// console.log(tasks.getTasksToDo())
// const add = (a, b, cb) => {
// setTimeout(() => {
// const res = a + b;
// return cb(res);
// }, 2000)
// }
// add(1,2,(sum)=>{
// console.log(sum)
// })
const greeter = (name = 'bob') => {
console.log('Hi ' + name)
}
greeter('alex')
greeter();