-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrello.js
More file actions
98 lines (53 loc) · 2.14 KB
/
trello.js
File metadata and controls
98 lines (53 loc) · 2.14 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
//const days = ['Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat']
// for (let i = days.length-1; i >= 0 ; i--) {
// console.log(days[i]);
// }
//days.reverse().forEach(element => console.log(element))
//days.forEach(function(element, index){
//console.log(`days of week number ${index + 1} is ${element}`)})
// const myTodos = []
// // myTodos.push('Buy Bread')
// // myTodos.push('Learn JS on Youtube')
// // myTodos.push('go for running')
// // myTodos.forEach(function(todo, index){
// // console.log(`Your task no. ${index+1} is: ${todo}`)
// // });
// myTodos.unshift('Buy Bread')
// myTodos.unshift('Learn JS on Youtube')
// myTodos.unshift('go for running')
// for (let index = 0; index < myTodos.length; index++) {
// console.log(`task no. ${index+1} is ${myTodos[index]}`)
// }
//array
const myTodos = ['Buy Bread', 'Go to Gym', 'Record youtube videos']
//multidimensional array - JS doesn't provide natively multi dimensional arrays,
//but we can have array of array elements.
//arrays are special type of objects in JS and array elements can
//be anything like integers, strings, objects, arrays, functions
//JS also doesn't natively provide associative arrays.
const newTodos = [
{title: 'Buy Bread',isDone: false},
{title: 'Go to Gym', isDone: false},
{title: 'Record youtube Videos', isDone: true}
]
// const index = newTodos.findIndex(function (element, index) {
// console.log(element)
// return element.title === 'Go to Gym'
// })
//console.log(index);
// const findTodo = function(sometodoArrayFromUser, searchTitle){
// const index = sometodoArrayFromUser.findIndex(function(element, index){
// return element.title.toLowerCase() === searchTitle.toLowerCase()
// })
// return sometodoArrayFromUser[index]
// }
// let printMe = findTodo(newTodos, 'Go To gym')
// console.log(printMe);
const findTodo = function (sometodoArrayFromUser, searchTitle){
const title = sometodoArrayFromUser.find(function(element, index){
return element.title.toLowerCase() === searchTitle.toLowerCase()
})
return title;
}
let printMe = findTodo(newTodos, 'go to gym')
console.log(printMe);