-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.js
More file actions
94 lines (76 loc) · 2.08 KB
/
application.js
File metadata and controls
94 lines (76 loc) · 2.08 KB
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
87
88
89
90
91
92
93
94
class NotesApplication{
constructor (author) {
//validate autor
this.author = author;
this.notelist = [];
}
/**
* Method create
*
* This function takes note content and add to notelist object
*/
create(note_content){
this.notelist.push(note_content);
//return this.notelist;
}
/**
* Method listNote
* This function list out note_id, the content and authors
*/
listNote(){
for(var i =0; i < this.notelist.length; i++ ){
console.log('Note Id :' + i );
console.log(this.notelist[i]);
}
console.log('By Author :' + this.author);
}
/**
*Method getNoteId
*This function takes in the note_id and return the note content as string
*/
getNoteId(note_id){
if(Math.abs(note_id) < this.notelist.length ){
console.log(this.notelist[note_id]);
}else{
console.log("Note Id is Not Valid");
}
}
/**
*Method searchText
*This function takes in a seach text and returns all note with that text within in
*/
searchText(search_text){
for(var i =0; i < this.notelist.length; i++ ){
if(this.notelist[i].includes(search_text)){
console.log('Showing result for search :' + '['+search_text+']');
console.log('Note Id :' + i );
console.log(this.notelist[i]);
console.log('By Author :' + this.author);
}else{
console.log('Search text not in search string');
}
}
}
/**
*Method deleteNote
*This function takes in note_id and delete the corresponding note from notelist
*/
deleteNote(note_id){
if(Math.abs(note_id) < this.notelist.length ){
delete this.notelist[note_id];
}else{
console.console.log("Note Id is Not Valid");
}
}
/**
*Method editNote
*This function takes in note_id and a new content and replace the old one
*/
editNote(note_id, new_content){
if(Math.abs(note_id) < this.notelist.length && new_content !== ""){
this.notelist[note_id] = new_content;
}else{
console.log( "Note Id is Not Valid");
}
}
}