Shahinian: Nidiffer: It’s actually a damn good exercise
Nidiffer: Rcyr yeah sure is lol but WHY ?
Shahinian: Nidiffer: You said it, because it shows you that you can do everything with a fold reduce
Nidiffer: Rcyr yeah yeah I know: trying to work that out now :-/
Shahinian: The next time you’ll have some special iteration to do that cannot be done using map/filter/etc. you’ll be able to do it using reduce.
Shahinian: You can also do multiple things with reduce in a single iteration that would normally require the combination of map/filter/every/some/etc
Nidiffer: But getting this done ain’t no easy job buddy lol :-/ let me try, see if I can get anywhere close to solution to this, Ive done this contains function, hopefully that might help me to do this every as well
Shahinian: Nidiffer: What ****s with your homework. JS isn’t the best language to do that.
Nidiffer: And this ain’t no simple every function lol since Im doing this in underbar.js it has some extra features and prerequisites it has to meet as well
Nidiffer: Rcyr yeah I know : but the school Im gonna attend is javascript based, and main concentration is javascript, so everything is JS in my school, I need to get everything work in JS, Ive 3 weeks left to submit back this pre-course I’ve
Mikowski: Can someone walk me through this line of js?
Mikowski: Img.element.style.display = index === -1 ? ‘none’ : ”;
Shahinian: Siba: the line before has a .indexOf, right?
Shahinian: Index = something.indexOf.
Mikowski: I’ve just never seen a line with = and === in it before
Shahinian: Siba: indexOf returns -1 when an element is not found
Nidiffer: Rcyr lol 😀 let me see how far I can actually GO go go! with this reduce and every mix lol
Shahinian: So, that line can be translated as: if index === -1 { img.element.style.display = ‘none’; } else { img.element.style.display = ” }
Shahinian: Siba: The ? : form is the conditional operator Often called ternary operator
Mikowski: Whats that called? is there some place i can read more about it?
Mikowski: Appreciate the help :
Nidiffer: Hmm rcyr check this out, those are prerequisites for every I need to meet, BUT.
Nidiffer: P***es by default for an empty collection, p***es for a collection of all-truthy results, fails for a collection of all-falsy results, fails for a collection containing mixed falsy and truthy results, should work when provided a collection containing undefined values, should cast the result to a boolean, should handle callbacks that manipulate the input, should work when no callback is provided
Nidiffer: What callback is it talking about? every doesn’t take any callbacks as far as Im concerned, does it?
Gull: It calls the predicate callback for each element, until false is returned
Mikowski: So just to clarify. it is setting the display style depending on the value of index. if its -1, it hides the image. if its anything else, it will show it
Nidiffer: Ahh damn! alright then. let me try to work this out
Nidiffer: Wwwaaoooo. surprisingly it wasn’t as hard as I thought would beat least making the core part to work, return true or false depending if all elements p*** or not, I did this part successfully 😀
Nidiffer: Well, yeah. I didn’t :-/
Nidiffer: I thought I got it right. but I didn’t properly used reduce, now Im trying to re-think the logic how I should implement it properly :-/
Nidiffer: Rcyr this was my initial solution, and to be fair it works. but probably I could have implemented it better right? https://repl.it/BG7W
Gapp: Hey what’s this agile development way of working all about
Shahinian: Nidiffer: Let me look
Nidiffer: For sure, I think it’s poorly done lol
Nored: Nidiffer: what is the problem you want solved
Nidiffer: Rcyr this is as whole I’ve, if this would help https://repl.it/BG7W/2