Rondell Ben
Rondell Ben

Reputation: 41

Value in object won't change

const filterField = {
  searchText: ''
  //Empty value to change over time.
}

const renderNotes = function (notes, filters) {
  const filteredNotes = notes.filter(function (note) {
    return note.title.toLowerCase().includes(filters.searchText.toLowerCase())
  }) 
  console.log(filteredNotes)
}
renderNotes(habits, filterField)

//This function is supposed to change the value of the filteredField object. 
  document.querySelector('#search-text').addEventListener('input', function (e) {
    filterField.searchText === e.target.value;
    renderNotes(habits, filterField);
  } ) 

The last method is supposed to change the value of the filterfield object. But it won't change.

I am following a tutorial on udemy and am stuck on this part.

Upvotes: 0

Views: 38

Answers (1)

steph
steph

Reputation: 21

filterField.searchText === e.target.value;

Too many equal signs:

  • Double equal checks for equality (value)
  • Triple equal checks for strict equality (value AND type)
  • Single equal assigns

change to

filterField.searchText = e.target.value;

Upvotes: 2

Related Questions