Activity
Mon
Wed
Fri
Sun
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
What is this?
Less
More

Memberships

Developer Pro

Public β€’ 144 β€’ Free

161 contributions to Developer Pro
Can someone explain to me how I can access my second array?
I completed the algo successfully, but I'm not quite sure how it all works lol Codewars: https://www.codewars.com/kata/5a3dd29055519e23ec000074/solutions/javascript My Code:https://codepen.io/Ricecakes_95/pen/BaXeeMx?editors=0012 Primarily, I'm confused as to why my filter method has access to array2.. Because I'm calling the filter method on array1 so obviously the values and indices should be available for array1, but why can I access array2?? Is this some type of implied access? Like I understand, since array2 exists, and it has data from the argument, that I'll have some access to array2 within the functional or block scope, but I thought I wouldn't have scope to access array2 within the filter method.. What am I missing? Thanks in advance smart people πŸ˜„
2
4
New comment 5h ago
0 likes β€’ 5h
@Cristian Florea So I think I shouldn't be able to access array2 because it's outside of the functional scope of the .filter method or in your case the forEach method. Yes I have initially the same access to both arguments once I invoke the function, but once I call array1.filter() then I don't understand how it can access array2. From your video you're making it sound like I should always have access to that argument. But then where does scope end? Does that make more sense? I've read Mioara's response and I'll need to do research about closures to better understand it. Also I wanted to use the filter method for the boolean value, not necessarily the shallow copy of the array. So I see where you're coming from that it's not the best approach or use of .filter().
0 likes β€’ 5h
@Mioara Cenusa It makes some sense but I'll need some time and research to clear things up, but thanks for the insight so I know what to look /research for!
Method Chaining in Action!
I'm finally getting to the point where my answers are pretty similar to a lot of the algos top 1 or 2 answers. This is my first "one-liner" I've been able to do in the last 2 months. I'm getting away from for loops as I try to challenge myself to solve them using the Array methods instead as I'm pretty comfortable with for loops as long as they're not nested. That "j" index is scary lol This isn't a difficult Algo by any means, but I've seen some cool ways to solve algos since I've been grinding the last 2 weeks and wanted to try new ways to get to the same result. Codewars link if you're curious: https://www.codewars.com/kata/5648b12ce68d9daa6b000099/solutions/javascript The biggest win was remembering that in the .map method you can directly access your nested array's elements using this syntax: var number = function(busStops){ return busStops.map( ([on, off]) => on - off).reduce( (acc, cur) => acc +=cur) } console.log(number([[10,0],[3,5],[5,8]])) The kata 7s are now being solved pretty quickly as I get back up to speed with all the different ways to iterate/"open" arrays. Getting my head around needing an array, variable, and for loop for everything is now slowly fading as I'm learning the redundancies in my code from all the other answers. Soon I'll be on your "one liner" level @Adelin Rosca hahaha
4
1
New comment 7h ago
This algo gives me a fatal crash when testing it
Here's the algo: https://www.codewars.com/kata/55f2b110f61eb01779000053/train/javascript Here's my answer (it works!): https://codepen.io/Ricecakes_95/pen/mdNYQXz I'm sure its too complicated but I couldn't think of an easier solution, other than breaking it down into steps. Let me know if you figure out why I'm getting a fatal error on codewars. Thanks!
5
10
New comment 2d ago
1 like β€’ 3d
@Mioara Cenusa Well without me knowing better ways to sort and remove duplicates this is my approach haha. Again I just piecemeal my problems one step at a time and build off of my code. I have no desire to refactor as I'm not even at that level. So you're right it's probably too much code but its how i did it.
1 like β€’ 2d
@Harpreet Singh I was going to use this method BUT it doesn't allow for negative integers. It has to be based off a value of 0-255
Thoughts on double for loops?
Hey guys, I see some answers being solved with double for loops in algos and so similar kind of question. I personally have only used this approach on an exercise a handful of times. But for those with more experience is this a concept I should become comfortable with? Thanks in advance!
3
9
New comment 7d ago
2 likes β€’ 9d
@Mioara Cenusa half of that wasn't English but I'll get there πŸ˜…πŸ˜‚
0 likes β€’ 9d
@Bret Miller ah finally layman's terms
Regex and your thoughts on it?
So i'm still just grinding away at some algos until i'm constantly completing level 6s in a timely fashion to really hone in my iteration skills / thought processes before continuing on in React. Of course regex comes up a lot in algos but I haven't seen much real world use for them. Do you think it's worth learning the syntax so you can understand how to read regex or do you just google until you find one that works for you? Let me know!
4
4
New comment 10d ago
0 likes β€’ 10d
@Bret Miller wise words
1-10 of 161
Trey Delcamp
6
1,326points to level up
@trey-delcamp-6128
Aspiring front end developer with a passion for eating

Active 5h ago
Joined Aug 15, 2023
powered by