|
@@ -18,6 +18,20 @@ const notes = [{
|
|
|
// return notes[index]
|
|
// return notes[index]
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const sortNotes = function (notes) {
|
|
|
|
|
+ notes.sort(function (a, b){
|
|
|
|
|
+ if (a.title.toLowerCase() < b.title.toLowerCase()) {
|
|
|
|
|
+ return -1
|
|
|
|
|
+ } else if (b.title.toLowerCase() < a.title.toLowerCase()) {
|
|
|
|
|
+ return 1
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return 0
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const findNote = function (notes, noteTitle) {
|
|
const findNote = function (notes, noteTitle) {
|
|
|
return notes.find(function (note, index) {
|
|
return notes.find(function (note, index) {
|
|
|
let currentTitle = String(note.title).toLowerCase()
|
|
let currentTitle = String(note.title).toLowerCase()
|
|
@@ -37,7 +51,7 @@ const findNotes = function (notes, query){
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-console.log(findNotes(notes, 'eating'))
|
|
|
|
|
|
|
+// console.log(findNotes(notes, 'eating'))
|
|
|
|
|
|
|
|
// const note = findNote(notes, 'office other modifications')
|
|
// const note = findNote(notes, 'office other modifications')
|
|
|
// console.log(note)
|
|
// console.log(note)
|
|
@@ -57,4 +71,7 @@ console.log(findNotes(notes, 'eating'))
|
|
|
// return note.title === 'Habits to work on'
|
|
// return note.title === 'Habits to work on'
|
|
|
// })
|
|
// })
|
|
|
|
|
|
|
|
-// console.log(index)
|
|
|
|
|
|
|
+// console.log(index)
|
|
|
|
|
+
|
|
|
|
|
+sortNotes(notes)
|
|
|
|
|
+console.log(notes)
|