« first day (2283 days earlier)      last day (2664 days later) » 

9:07 PM
here is my fiddle where I am working on jsfiddle.net/uykx5y0b
 
@neoDev See Array.prototype.filter
 
@MadaraUchiha I tried also that one, but without success
please can you help me?
 
@neoDev What have you tried with .filter?
 
yes, I taken it from the link I posted above
 
!!> ['math', 'mango', 'man', 'fruit'].filter(item => item.startsWith('ma'));
 
9:09 PM
@MadaraUchiha ["math","mango","man"]
 
You aren't removing duplicates
You don't have duplicates
You're filtering the array
 
I need to remove duplicates-starting-with specific charaters
 
@neoDev Well, the example you gave has no duplicates in it
So please give a better example.
 
I told you guys, for "duplicates" I mean duplicates-starting-with specific charaters
 
@neoDev That doesn't make sense...
What's the expected output?
 
9:11 PM
array = ['math', 'mango', 'man', 'fruit']
expected result:
array = ['math', 'fruit']
 
choosing only the first one starting with "ma"
 
What's the criteria? first two characters?
 
yes :)
 
!!> ['math', 'mango', 'man', 'fruit'].filter((s, i, a) => a.find(x => x[0] === s[0] && x[1] === s[1]) === s)
 
9:13 PM
@david ["math","fruit"]
 
const seenPrefixes = new Set();
const arr = ['math', 'mango', 'man', 'fruit'];

let result = [];

for (const item of arr) {
  if (!seenPrefixes.has(item.slice(0, 2))) { result.push(item); }
  seenPrefixes.add(item.slice(0, 2));
}

console.log(result);
Or something like that, I haven't tested it
 
@david @MadaraUchiha thank you guys, all the examples work great!
I love you !!! :)
 
if you had no uni certification, would employers look at your highschool marks?
 
:)
thanks
 
@david one letter variables =_=
 
9:17 PM
ohh wait david's one not working
it returns the array untouched
 
@neoDev .filter always returns a new array
 
@MadaraUchiha i don't only use 1 character variable names, i switch to 2 characters once i hit 26 total variables
 
ok keeping it one line works sorry
 
@ray9209 devtool is lowercase, but I'm not sure if it matters. I just tried '#source-map' and it worked. chrome pulls up the original file, too.
 
it's just hard to understand xD
for me that I'm noob
 
9:20 PM
26 variables is too many variables.
 
var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
Seems perfect.
 
@phenomnomnominal leave out one letter for a fun bug
arse
 
@david can you show how I can modify your example to select first 3 characters instead of 2?
It's hard to understand
 
repeat the block using [2] instead of [0] or [1]..
 
ahaha, what on earth are you trying to do neoDev? I intentionally made it obscure to encourage you to figure it out yourself, why do you suddenly need 3 letters?
 
9:35 PM
to understand how it works
first of all I am thankful to you
but I never used => in javascript
 
=> is just a function
(function(x) {return x;}) is the same as x => x
maybe use @MadaraUchiha if you actually want to learn how to do it
 
I imagined it and I tried to subsitute them with functions... without luck
 
show us.
 
9:37 PM
you aren't returning anything in the function.
for filter.
 
@neoDev do you develop with the console open? can you see the errors that it's throwing?
 
@Luggage I'm also confused about blocks you're talking about
@david yes
 
also, invalid syntax somewhere
 
(index):47 Uncaught SyntaxError: Unexpected token )
now I try to add return
 
@neoDev jsfiddle.net/ctrlfrk/xvtne0f0/1 here it is fixed
 
9:40 PM
you are a so nice person
I wondered when exactly my brain explode
well, now the block
I suppose I have to change this
return x[0] === s[0] && x[1] === s[1];
with
return x[0] === s[0] && x[1] === s[1] && x[2] === s[2];
?
 
yeah, or if you're going to extend it like that, just replace the entire thing with x.slice(0, 2) === s.slice(0, 2);
so you can change it to x.slice(0, 3) === s.slice(0, 3);
or even x.slice(0, 99) === s.slice(0, 99); without your code size exploding
 
one day I want to become like you :)
 
no, you really don't want that
 
you know your programming in javascript when every variable is a letter, it's crazy how much this X variable gets done around here.
 
yes instead
 
9:48 PM
you need to remember that in a chatroom environment people tend to write code quickly. That means you don't have a lot of time to think up descriptive variable names. If you're copying someone's code and it's full of single letter names you should probably read through it, understand it, and give the variables proper names.
it will help you in many ways
 
I agree boss
this can save lifes
 
@neoDev Especially yours
 
:D
and make it more interesting
 
Given that you should always code as if the next person to touch your code is a homicidal maniac who knows where you live.
 
and isn't you yourself
 
9:54 PM
@david Especially if it's you yourself!
Never trust future you...
 
but i don't think future me will kill himself because of past me :S
that's a little dark
 
As usual my attempt at being funny or ironic completely backfires.
 
what did you do?
 
I don't know how to ref what I said above properly, but yeah that statement :D
Man I'm at hour 27 and I'm near completing the first assignment
 
@david self referencing test post plz ignore
:35117026 test
 
9:58 PM
13 hours and 2 minutes till handin for second assignment
 
aha, that one actually references itself
 
need to pull 1k words out of my ass
@MadaraUchiha When's the javascript room getting voice channels :D? Would be neat
 
10:14 PM
@lix What's the subject?
 
10:36 PM
Does anyone know why there are conflicting "Added in" versions between Buffer.from in 4.x and Buffer.from in latest? cc @BenjaminGruenbaum
 
@david you there?
 
@lix you go girl!
 
@OliverSalzburg maybe the changed signature for the Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]]) method?
@neoDev yeah
 
can you help me with the very last thing for today?
 
@david The plain Buffer.from(array) is in both versions
 
10:39 PM
just skip the exact duplicates with the previous code
 
@OliverSalzburg yeah, but it's the same method just with different signatures. If one of the signatures changed it might update all of them
 
that at the moment are not removed jsfiddle.net/6dLfkth5
 
@david Ah, good call
 
afaik, historically there's only been the big change that you don't use new Buffer(source) but Buffer.from(source)
 
just changed the find call to findIndex and compared to the index rather than the string.
now identical strings at different indices won't match anymore
 
10:45 PM
wow I didn't imagine you being so fast omg
THANK YOU
it's just perfect for me
:)
 
If you understand what code is doing then it's quite easy to make changes to it
 
it makes perfectly sense
I have 12 remaining minutes before my curfew... I can't believe I'm doing it in time
All thank to you
I have to hurry up
 
curfew? o_O
 
I read deadline
Aka assignment
 
@FilipDupanović cheers ombrey o/
 
10:55 PM
done!
yess
tomorrow I'll try to learn properly js promises
 
properly?
 
I bookmarked this for now: medium.freecodecamp.com/…
yes because I never used them yet
but they sound cool for several purposes
:)
ok guys, I have to go
MANY MANY MANY THANKS!
have a wonderful night :)
bye
 
11:24 PM
Hello guys
I have some problem in my script jsfiddle.net/xbuppd1r/1
Uncaught SyntaxError: Unexpected token h in JSON at position 0
do you know why ??
 
that's not the code that's giving you the error is it?
why are you calling JSON.parse( with "all.json"? that makes no sense
 
You should be getting $ is not defined
 
@monners nah man, if you're having a problem just copy paste some unrelated code into jsfiddle, don't bother running it, and then dump the link into SO chat. that's webscale
 
without JSON.pars i have Uncaught TypeError: Cannot use 'in' operator to search for '83' in
i don't understand
 
So you're putting in a new error because it suppresses a different error later in your code?
the code you linked doesn't even use an 'in' operator
your shit is fucked on more levels than i can deal with right now, i'm going to get lunch bbiab
 
11:33 PM
:/
I just want to understand why this does not work
 
might want to start with the documentation on JSON.parse() developer.mozilla.org/en/docs/Web/JavaScript/Reference/…
 
ok thx
 
11:54 PM
@Unmecparla yeah sorry i was a bit mean there. Where are you getting this code from? is it copied from somewhere or are you writing it yourself? where is it actually running? that jsfiddle doesn't work
 

« first day (2283 days earlier)      last day (2664 days later) »