Categories
Mastering Development

How to use a cut in prolog to find the number of daughters?

Exercise: Observe the family structure below where each person has a gender specification as their third parameter (m = male, f = female). Use a cut to write the predicate numDaughters(L, Count) in such a way that family(Husband, Wife, Kids), numDaughters([Husband, Wife|Kids],X) lists each family in the database and the number of daughters in each […]

Categories
Mastering Development

Javascript: How to conditionally add a property to certain objects in an array dynamically and maintain the original order of the array

This question is related to this and this questions. I have an array like so. const questions = [ { _id: 1, q: ‘why?’, group: ‘no-group’, date: ‘8’, selected: false }, { _id: 2, q: ‘what?’,group: ‘no-group’, date: ‘6’, selected: false }, { _id: 3, q: ‘when?’,group: ‘no-group’, date: ‘7’, selected: false }, { _id: […]