These are chat archives for FreeCodeCamp/Help

19th
Sep 2018
Lance
@texas2010
Sep 19 2018 00:02
@thekholm80 lol
Kyle Holm
@thekholm80
Sep 19 2018 00:05
@texas2010 :wave:
psyperl
@psyperl
Sep 19 2018 00:25
@psyperl :wave:
psyperl
@psyperl
Sep 19 2018 00:36

i found my naming convention for promises now so i decided instead of doing

const someFunction = x => 
  new Promise( (kept, broken) => fetchResourceA().then(kept, broken) )

i structure it this way to be more readable

/// Promise function should have 'to' prefix
const toHaveResourceA = (kept, broken ) => 
  fetchResourceA().then(kept, broken)

const someFunction = _ => 
  new Promise(toHaveResourceA )
    .then(console.log, console.error)
Kyle Holm
@thekholm80
Sep 19 2018 00:37
why the underscore?
psyperl
@psyperl
Sep 19 2018 00:37
gone
Kyle Holm
@thekholm80
Sep 19 2018 00:38
generally people use those in js to indicate a static method
psyperl
@psyperl
Sep 19 2018 00:38
ah ok
good to know
Kyle Holm
@thekholm80
Sep 19 2018 00:38
or, by itself an unused argument like your second function
throw away args
err .. maybe it's private methods not static
psyperl
@psyperl
Sep 19 2018 00:40
i often use them for a private function .. well not necessarily private in js .. but functions that are not related to use cases
yeah
Kyle Holm
@thekholm80
Sep 19 2018 00:40
i'm old, i forget stuff
sorry
psyperl
@psyperl
Sep 19 2018 00:40
lol no worries
Kyle Holm
@thekholm80
Sep 19 2018 00:40
:grin:
psyperl
@psyperl
Sep 19 2018 00:41
life starts at 60 .. no worries :smile:
Kyle Holm
@thekholm80
Sep 19 2018 00:41
oh sweet, i'm half way there
psyperl
@psyperl
Sep 19 2018 00:41
haha
i will need to get used to with these structures then i will go to async await :D
Kyle Holm
@thekholm80
Sep 19 2018 00:43
i think you'll love it
psyperl
@psyperl
Sep 19 2018 00:43
hope so yeah
Kyle Holm
@thekholm80
Sep 19 2018 00:43
it makes so much sense (to me at least)
Manish Giri
@Manish-Giri
Sep 19 2018 00:47
Kyle Holm
@thekholm80
Sep 19 2018 00:49
that's ugly
but i think i have a plausible solution
Manish Giri
@Manish-Giri
Sep 19 2018 00:50
hopefully not return "ava\nwel"
:smirk:
Kyle Holm
@thekholm80
Sep 19 2018 00:50
lol
meta testing is the only way
Kyle Holm
@thekholm80
Sep 19 2018 01:00
@Manish-Giri got it
kinda ugly though
Manish Giri
@Manish-Giri
Sep 19 2018 01:01
:fire:
let's take a look
Kyle Holm
@thekholm80
Sep 19 2018 01:04
function getSmallestAndLargest(s, k) {
    const subs = [];

    while (s.length >= 3) {
        subs.push(s.substr(0, k));
        s = s.substring(1);
    }

    subs.sort((a, b) => a.localeCompare(b));

    return `${ subs[0] }\n${ subs[subs.length - 1] }`;
}
Manish Giri
@Manish-Giri
Sep 19 2018 01:06
nice
:thumbsup:
Kyle Holm
@thekholm80
Sep 19 2018 01:06
i'm not proud of it lol
but it gets the job done
psyperl
@psyperl
Sep 19 2018 01:12
oo template literals
i often forgot to make use of them
Kyle Holm
@thekholm80
Sep 19 2018 01:13
i hate string concatenation
psyperl
@psyperl
Sep 19 2018 01:13
same
Kyle Holm
@thekholm80
Sep 19 2018 01:13
all those + so ugly
Manish Giri
@Manish-Giri
Sep 19 2018 01:15
    public static String getSmallestAndLargest(String s, int k) {
        TreeSet<String> chunks = new TreeSet<>();
        for (int i = 0; i <= s.length() - k; i++) {
            chunks.add(s.substring(i, i+k));
        }
        return chunks.first() + "\n" + chunks.last();
    }
one of those times you thank java for having good DSs :smile_cat:
Kyle Holm
@thekholm80
Sep 19 2018 01:16
that's not awful
and i almost understand it
Manish Giri
@Manish-Giri
Sep 19 2018 01:19
:thumbsup:
TreeSet is the real magic
lol
Kyle Holm
@thekholm80
Sep 19 2018 01:20
a JS set could be a good idea here, dunno what the other test cases look like but it would mean not sorting a ton of identical values
Manish Giri
@Manish-Giri
Sep 19 2018 01:21
does JS set have sorting
:thought_balloon:
Kyle Holm
@thekholm80
Sep 19 2018 01:21
i figured i'd use Set.add() then Array.from(set).sort()
but you might be able to sort a set directly
doesn't look like it
Manish Giri
@Manish-Giri
Sep 19 2018 01:22
not sure if there's any benefit to using Set
unless there are duplicates in other test cases
Kyle Holm
@thekholm80
Sep 19 2018 01:22
negligible, if any
sorting is slow though so weeding out dups can be beneficial
Manish Giri
@Manish-Giri
Sep 19 2018 01:25
:thumbsup:
Kyle Holm
@thekholm80
Sep 19 2018 01:27
@Manish-Giri x
Manish Giri
@Manish-Giri
Sep 19 2018 01:28
dafuk
lol
Kyle Holm
@thekholm80
Sep 19 2018 01:28
dunno if i'd kayak there anymore
Manish Giri
@Manish-Giri
Sep 19 2018 01:28

the croc there is like

oh hey how you doin

Kyle Holm
@thekholm80
Sep 19 2018 01:40
@Manish-Giri data scientists are so awesome
you should sub r/dataisbeautiful if you haven't yet
Manish Giri
@Manish-Giri
Sep 19 2018 01:41
yea i've subbed to it
some posts there are nice
Kyle Holm
@thekholm80
Sep 19 2018 01:42
yeah
Kyle Holm
@thekholm80
Sep 19 2018 01:44
now that is incredible
Manish Giri
@Manish-Giri
Sep 19 2018 01:47
its almost like canada
northern side is equally uninhabited
psyperl
@psyperl
Sep 19 2018 02:16

oo i am having weird problem..

somePromis()
  .then( anotherPromise().catch(console.warn ) ) // this one would catch

but

somePromis()
  .then( anotherPromise() )
  .catch( console.warn )  // this one wouldn't catch

wonder what's wrong.. my understanding about the promise flow is not clear then

Kyle Holm
@thekholm80
Sep 19 2018 02:17
think about what is returning what
psyperl
@psyperl
Sep 19 2018 02:17
i thought both code is equal
Kyle Holm
@thekholm80
Sep 19 2018 02:17
somePromis() <-- this is what your catch statement is chaining off of
psyperl
@psyperl
Sep 19 2018 02:17
the anotherPromise() is returning Promise?
Kyle Holm
@thekholm80
Sep 19 2018 02:17
it's returning a promise inside the then()
psyperl
@psyperl
Sep 19 2018 02:17
yes
Kyle Holm
@thekholm80
Sep 19 2018 02:18
so you have to catch it in that
psyperl
@psyperl
Sep 19 2018 02:18
oh
psyperl @psyperl thinking
Kyle Holm
@thekholm80
Sep 19 2018 02:20
somePromis() // returns a promise
.then(/* this happens in it's own context */) // this is invoked on the returned value of somePromis()
.catch(/* this happens in it's own context */)  // this is invoked on the returned value of somePromis()
psyperl
@psyperl
Sep 19 2018 02:20
how about
somePromise()
  .then( anotherPromise() )
  .then( x => x.catch( console.warn ) ) // would this work?
somePromis() // returns a promise
.then(/* this happens in it's own context */) // this is invoked on the returned value of somePromis()
.catch(/* this happens in it's own context */)  // this is invoked on the returned value of somePromis()
ahh that's clear
Kyle Holm
@thekholm80
Sep 19 2018 02:21
i think it would be
somePromise()
  .then( return anotherPromise() )
  .then( x => x.catch( console.warn ) )
psyperl
@psyperl
Sep 19 2018 02:21
let me check
Kyle Holm
@thekholm80
Sep 19 2018 02:21
the .then() chains off of the returned value
psyperl
@psyperl
Sep 19 2018 02:22
it should.. but it didn't work it seems
Kyle Holm
@thekholm80
Sep 19 2018 02:23
yeah, i'm not surprised
this is why we end up with sideways pyramids
psyperl
@psyperl
Sep 19 2018 02:23
the x was a return value .. not the promise.. hmm
Aditya
@ezioda004
Sep 19 2018 02:23
Shouldnt it be .then(anotherPromise)? Since you have no callback function so anotherPromise is acting as callback function
Kyle Holm
@thekholm80
Sep 19 2018 02:23
or 'callback hell'
Aditya
@ezioda004
Sep 19 2018 02:23
I prefer "callback christmas tree of doom"
Kyle Holm
@thekholm80
Sep 19 2018 02:24
i prefer async / await
callbacks make me unhappy
psyperl
@psyperl
Sep 19 2018 02:24
ugh do i have to learn async await now ? :(
but
somePromise()
  .then( anotherPromise() )
  .catch( console.warn )  ///  how this catch is only for somePromise() surprised me
Aditya
@ezioda004
Sep 19 2018 02:25
Its not a new mechanism, more syntactic sugar
Kyle Holm
@thekholm80
Sep 19 2018 02:26
i remember doing the twitch api project in the old curriculum. it was so not fun
getAPIData().then(data => getMoreAPIData.then(getEvenMoreAPIData().then(/* ugh */)))
that was my first experience with callback christmas tree of doom
Aditya
@ezioda004
Sep 19 2018 02:27
I still think .then( anotherPromise()) is wrong
.then() accepts a callback function, so either do .then(x => somePromise()) or .then(somePromise), otherwise .then(somePromise()) would be invoked twice
Kyle Holm
@thekholm80
Sep 19 2018 02:27
yeah
it's like when you add a function to an event handler, () will pass the result of the function instead of the function itself
Aditya
@ezioda004
Sep 19 2018 02:28
Yeah "inversion of control" is still a thing with promises
psyperl
@psyperl
Sep 19 2018 02:29
.then( anotherPromise()) is fine .. this case i don't need the previous passing param
Kyle Holm
@thekholm80
Sep 19 2018 02:30
but like @ezioda004 said anotherPromise() will be called before the then()
Aditya
@ezioda004
Sep 19 2018 02:30
It'll be invoked twice, unless thats the intended behavior
psyperl
@psyperl
Sep 19 2018 02:31
nope .. is not intended .. let me double check .. although i confused how it's invoked twice
Aditya
@ezioda004
Sep 19 2018 02:31
Its like doing element.addEventListener("click", callback())
You dont call the callback function, the method calls it when something triggers
psyperl
@psyperl
Sep 19 2018 02:32
it only called it once
i don't think that's the problem though about not catching the thrown error
but wait
yeah
maybe
coz it's calling the return
from anotherPromise instead
not calling twice.. but calling the return from anotherPromise .. hmm maybe i know why the catch failed
psyperl
@psyperl
Sep 19 2018 02:37
@ezioda004 awesome .. yeah that's the problem .. it loose context because it's returning the value instead of the promise instead
@thekholm80 @ezioda004 thank you!
somePromise()
  .then( _ => anotherPromise() )
  .catch( console.warn )
this works!
Kyle Holm
@thekholm80
Sep 19 2018 02:38
there you go
i'm embarrassed i didn't see it
@ezioda004 is awesome
psyperl
@psyperl
Sep 19 2018 02:39
yeah well i made that mistake in the first place :p
Aditya
@ezioda004
Sep 19 2018 02:39
Hmm interesting, its not called twice which I presumed
function y(x){
  console.log("hello world", x);
}
Promise.resolve(1).then(y(x)) //hello world Promise {<resolved>: Ζ’};
function y(x){
  console.log("hello world", x);
}
Promise.resolve(1).then(y); //hello world 1
psyperl
@psyperl
Sep 19 2018 02:41
yeah it's calling what the promise return which is undefined
Aditya
@ezioda004
Sep 19 2018 02:41
It'll pass the returned value from first promise as parameter to the callback function automatically
psyperl
@psyperl
Sep 19 2018 02:43
const secondCall = x => console.log("yay")
function y(x){
  console.log("hello world", x);
  return secondCall
}
Promise.resolve(1).then(y())
that might clear the confusion
but
function y(x){
  console.log("hello world", x);
  /// returning undefined
}
Promise.resolve(1).then(y())  // pretty much caling undefined()
Aditya
@ezioda004
Sep 19 2018 02:45
Ohh its actually indeed calling twice, but its calling the returned value, jeez I feel dumb
psyperl
@psyperl
Sep 19 2018 02:45
join the club!
Kyle Holm
@thekholm80
Sep 19 2018 02:45
got room for me?
psyperl
@psyperl
Sep 19 2018 02:46
:smiley:
Kyle Holm
@thekholm80
Sep 19 2018 02:46
i'm pretty busy most days with the 'we hate kyle club' but i can probably make the meetings
Aditya
@ezioda004
Sep 19 2018 02:46
const secondCall = x => console.log("yay")
function y(x){
  console.log("hello world", x);
  return secondCall
}
Promise.resolve(1).then(y) //hello world 1
const secondCall = x => console.log("yay")
function y(x){
  console.log("hello world", x);
  return secondCall
}
Promise.resolve(1).then(y(x)) //hello world Promise, yay
@thekholm80 I saw an opening for VC for that club, might apply
Kyle Holm
@thekholm80
Sep 19 2018 02:47
you really should. sometimes there's cookies
Aditya
@ezioda004
Sep 19 2018 02:48
HOFs are tricky business, I respect those Haskell people
Kyle Holm
@thekholm80
Sep 19 2018 02:48
i get them all sorted out, then i don't use them for months and i have to work to understand them all over again
Aditya
@ezioda004
Sep 19 2018 02:49
Same lol, I'm sure if if you asked me to explain the above example in couple of months I'll trip again
WaterLemonade
@WaterLemonade
Sep 19 2018 07:42
hello
howtoadd a paragraph
Ene Catalin
@EneCatalin
Sep 19 2018 07:43
google html how to add image
Ene Catalin
@EneCatalin
Sep 19 2018 07:48
@WaterLemonade any luck ?
May Kittens Devour Your Soul
@diomed
Sep 19 2018 07:55
what do you call witch that only eats sand?
May Kittens Devour Your Soul
@diomed
Sep 19 2018 08:08
@ezioda004 haskell people are lizard people
Aditya
@ezioda004
Sep 19 2018 08:09
@diomed sandwich?
May Kittens Devour Your Soul
@diomed
Sep 19 2018 08:20
@ezioda004 what? NO malnourished
Aditya
@ezioda004
Sep 19 2018 08:22
:cat: :gun:
Kranti Nebhwani
@darkphotonKN
Sep 19 2018 10:16
guys whats a good way to keep a div, say a title for a picture on a page, "attached" to the image so the move as one unit? Currently I tried putting them both in one div but is there no other way
so basically two things moving as one, an image and it's title
Johnny
@JohnnyBizzel
Sep 19 2018 10:19
@darkphotonKN figcaption ?
he gone...
Aditya
@ezioda004
Sep 19 2018 10:26
Yeah figcaption seems like what you need
Kranti Nebhwani
@darkphotonKN
Sep 19 2018 10:28
thanks @JohnnyBizzel
Johnny
@JohnnyBizzel
Sep 19 2018 10:29
@darkphotonKN :+1:
May Kittens Devour Your Soul
@diomed
Sep 19 2018 12:08
I like bagels because they're empty inside, just like me
Aditya
@ezioda004
Sep 19 2018 12:12
void Array("diomed").fill('🐱');
psyperl
@psyperl
Sep 19 2018 12:17
:donut:
Xarri Jorge
@xarrijorge
Sep 19 2018 12:27
Heya folks : wave:
:wave:
Anyone knows if I can still apply for the FCC hackathon in October?
psyperl
@psyperl
Sep 19 2018 12:33
somehow i never really fancy that term
i prefer 'code challenge'.. sounds more civilized :smile:
Aditya
@ezioda004
Sep 19 2018 12:52
@xarrijorge Yes, you'll need to create a quick gatsby-netlify app and then you can apply
https://forum.freecodecamp.org/t/freecodecamp-2018-jamstack-hackathon-at-github-in-san-francisco-on-october-27-28/221604
Xarri Jorge
@xarrijorge
Sep 19 2018 12:53
okay, so do you know if I can still apply for the code challenge? @psyperl
Thanks @ezioda004
Aditya
@ezioda004
Sep 19 2018 12:55
Gonna apply aswell, seems fun
psyperl
@psyperl
Sep 19 2018 12:55
good luck @xarrijorge @ezioda004
Aditya
@ezioda004
Sep 19 2018 12:56
@psyperl You dont want to?
I think its team based
psyperl
@psyperl
Sep 19 2018 12:57
i don't think i would yeah
i would next year if they change the name to code challenge haha
Aditya
@ezioda004
Sep 19 2018 12:57
Lol, whatsinthename
psyperl
@psyperl
Sep 19 2018 12:58
whackaton
Aditya
@ezioda004
Sep 19 2018 12:58
Good one, that should be a real thing
psyperl
@psyperl
Sep 19 2018 12:58
lol
Xarri Jorge
@xarrijorge
Sep 19 2018 13:04
Yeah, it should be fun if nothing else
@ezioda004
I'll add that as an issue on the FCC repo @psyperl
psyperl
@psyperl
Sep 19 2018 13:04
@xarrijorge lol
Aditya
@ezioda004
Sep 19 2018 13:06
Yeah I've never participated in a hackathon before, I'm sure I'll learn something
May Kittens Devour Your Soul
@diomed
Sep 19 2018 13:57
you+ll get h4ck3ed
Xarri Jorge
@xarrijorge
Sep 19 2018 14:01
Just completed the application @ezioda004
Aditya
@ezioda004
Sep 19 2018 14:02
:star2:
May Kittens Devour Your Soul
@diomed
Sep 19 2018 14:25
@ezioda004 d3 - option one / option 2 / intersection? possible?
Aditya
@ezioda004
Sep 19 2018 14:28
Idk d3
May Kittens Devour Your Soul
@diomed
Sep 19 2018 14:28
do you know any JS graph?
Aditya
@ezioda004
Sep 19 2018 14:30
No, but I know tree
May Kittens Devour Your Soul
@diomed
Sep 19 2018 14:31
lol
Kyle Holm
@thekholm80
Sep 19 2018 14:47
i know graphql
D3 is pretty awesome but chart.js is easier to work with @diomed
in my noobish opinion
May Kittens Devour Your Soul
@diomed
Sep 19 2018 14:59
I agree . Am just checking out chart.js
Kyle Holm
@thekholm80
Sep 19 2018 15:00
also, sparklines is pretty fun if you don't have complex data you want to display
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:23
that's like tiny chart of smth
Kyle Holm
@thekholm80
Sep 19 2018 15:30
yeah. very small charts for simple data
they're easy to animate though, so they can be fun
Smootimus
@Smootimus
Sep 19 2018 15:47
That was so satisfying
I got a 103% on my C++ final :D
Kyle Holm
@thekholm80
Sep 19 2018 15:47
:poop: ?
oh, test
Smootimus
@Smootimus
Sep 19 2018 15:47
Somewhere I got some kind of extra credit lol
Oh a :poop: would be as well
Kyle Holm
@thekholm80
Sep 19 2018 15:47
very cool
Smootimus
@Smootimus
Sep 19 2018 15:47
But that was earlier xD
Yeah I opted to actually take the Final
And i wrecked that thing :D
I didn't expect to get a 103, tho
That surprised me
Kyle Holm
@thekholm80
Sep 19 2018 15:48
now that you're a c++ pro you can teach me
Smootimus
@Smootimus
Sep 19 2018 15:48
Let's do it! :D
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:48
darn those teachers today. you can't get 103% out of 100% that's like getting participation trophy
Smootimus
@Smootimus
Sep 19 2018 15:48
LOL I KNOW right?!
I was like "Where did the 3 come from?"
She probably gave me that because
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:49
sorry. you overcalculated
Smootimus
@Smootimus
Sep 19 2018 15:49
I'm the only student that did ALL of the extra credits
Kyle Holm
@thekholm80
Sep 19 2018 15:49
she's got the hots for smoot
Smootimus
@Smootimus
Sep 19 2018 15:49
Yet I still opted to do the Final
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:49
@Smootimus got 5*
Smootimus
@Smootimus
Sep 19 2018 15:49
That, too :eyes: lol
Kyle Holm
@thekholm80
Sep 19 2018 15:49
she gives you an a, redacted
Smootimus
@Smootimus
Sep 19 2018 15:49
xD!!
Ahahahaa
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:49
wakka wakka wakka wakka
Smootimus
@Smootimus
Sep 19 2018 15:50
Ya'll seent the movie A Beautiful Mind?
Kyle Holm
@thekholm80
Sep 19 2018 15:50
yep
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:50
yep
Smootimus
@Smootimus
Sep 19 2018 15:50
Pretty sweet movie, I watched it last night
Kyle Holm
@thekholm80
Sep 19 2018 15:50
it was pretty creepy
Smootimus
@Smootimus
Sep 19 2018 15:50
Yeah it was LOL
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:50
I still talk with my friends, unlike him
Smootimus
@Smootimus
Sep 19 2018 15:50
Haha
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:50
shame on you, Russel Mathematician Crowe
Kyle Holm
@thekholm80
Sep 19 2018 15:51
i kind of want to get a bunch of newspapers and magazines, circle some random words, put them in an envelope and stash it somewhere public
Smootimus
@Smootimus
Sep 19 2018 15:51
Shame, shame he knows his name
Right? I wanna go to an abandoned building and start stuffing TS information in it's mailbox
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:51
cannot wait for Russel Crowe to be in Bojack Horseman TV show.
He'd probably be crow
Smootimus
@Smootimus
Sep 19 2018 15:52
Or what I've convinced myself is TS info
I almost :poop: my pants when I realized what was REALLY happening
That his friends were the "Russians" that were following him, seeing what he was doing
Brain :boom:
Kyle Holm
@thekholm80
Sep 19 2018 15:53
now go watch kpax
Smootimus
@Smootimus
Sep 19 2018 15:53
:O What's that?!
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:53
that's the movie about soap
bubbles
Kyle Holm
@thekholm80
Sep 19 2018 15:53
kevin spacy is an alien. maybe
Smootimus
@Smootimus
Sep 19 2018 15:54
OoOoO
I'm putting it on the list
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:54
K-PAX is good movie
Smootimus
@Smootimus
Sep 19 2018 15:54
Yeah it's at the top of the list now
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:54
got nice soundtrack as well
Aditya
@ezioda004
Sep 19 2018 15:56
The imitation game (Alan Turning) is nice, similar to beautiful mind
Smootimus
@Smootimus
Sep 19 2018 15:56
Yeah that one is a nice one
Kyle Holm
@thekholm80
Sep 19 2018 15:56
i haven't seen that yet
i think it's on prime, i'll have to check
Smootimus
@Smootimus
Sep 19 2018 15:56
I saw that one a while back, been quite awhile actually
May Kittens Devour Your Soul
@diomed
Sep 19 2018 15:57
then years after that came John Cusack and said , ok I wanna be from another planet
and they said - no, you're not good enough. you can play guardian of a child from another planet - hence - Martian Child
Immitation Game is just Benadryl Cucumber creating some PC in his workplace...
just being Benadryl Cucumber
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:08
@thekholm80 make me blue and red vue-bars and when they overlap they be prpl
Kyle Holm
@thekholm80
Sep 19 2018 16:10
i don't know how
Aditya
@ezioda004
Sep 19 2018 16:17
Thats simple, step 1 npm install --save react react-dom
Kyle Holm
@thekholm80
Sep 19 2018 16:19
that's too easy
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:22
vue eats react for breakfast :yum:
haha, I'm just kidding
react is yuck. tasteless
Kyle Holm
@thekholm80
Sep 19 2018 16:23
aww it's cute when you have opinions
even when they're horribly wrong
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:24
I dont have to be right.
In the end it's not about what's better, but what gets job done.
Kyle Holm
@thekholm80
Sep 19 2018 16:24
true
but if you want me to get the job done, vue isn't the way
Aditya
@ezioda004
Sep 19 2018 16:25

In the end it's not about what's better, but what gets job done.

Agreed but lets not talk logical here

psyperl
@psyperl
Sep 19 2018 16:26
is not about getting the jobs done, most of the time is always how to get the jobs done
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:26
@ezioda004 ok sorry.
so, as we were
VUE IS THE BEST!!!! Damn you react
diomed @diomed curses react with balls of :fire: :fire:
Aditya
@ezioda004
Sep 19 2018 16:31
We all know squirtle is the best
alpox
@alpox
Sep 19 2018 16:32
@diomed some day youll come crawl back to react
psyperl
@psyperl
Sep 19 2018 16:45
glad i've never tried both of them :trollface:
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:48
Nicolas Ramirez
@kamatheuska
Sep 19 2018 16:48

can someone give me a hand with the cashRegister algorithm?

function checkCashRegister(price, cash, cid) {
    let changeDue = cash - price
    let count = changeDue
    let totalCash = cid.reduce((cur, unit) => +(cur + unit[1]).toFixed(2), 0)
    let currencyNetWorth = [0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 100].reverse()

    const countCashUnits = (cashInCurrency, curIndex) => {
        let curUnits = Math.floor(count / currencyNetWorth[curIndex])
        if (curUnits < 1)
            return cashInCurrency.map((el, i) => i === 1 ? 0 : el)
        else {
            // Subtract the current count of change
            let curTotal = curUnits * currencyNetWorth[curIndex]
            let foo = curTotal - (curTotal - cashInCurrency[1])
            count = + (count - curTotal).toFixed(2)
            return cashInCurrency.map((el, i) =>
                i === 1 ? foo : el)
        }
    }
    const getChange = (cashRegister) => {
        let result = cashRegister
            .reverse()
            .map((currency, index) => countCashUnits(currency, index))
            .filter((currency) => currency[1] !== 0)

        return changeDue !== 0 ? result : false
    }
    let finalChange = getChange(cid)
    return totalCash === changeDue
        ? { status: "CLOSED", change: cid }
        : totalCash < changeDue || !finalChange
            ? { status: "INSUFFICIENT_FUNDS", change: [] }
            : { status: "OPEN", change: finalChange }
}

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register/
This is what I have until now...help pleaseeee

Xarri Jorge
@xarrijorge
Sep 19 2018 16:49
Vue is kinda the one that never could!
Nice to know but no one is loosing sleep if you don't
Nicolas Ramirez
@kamatheuska
Sep 19 2018 16:51
BTW., Vue is just the best.
need a hand, it is my last algorithm challenge :O :O
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:53
@xarrijorge never could what?
@ezioda004 where u at? sm1 needs an algo help.
Xarri Jorge
@xarrijorge
Sep 19 2018 16:54
React folks would know @diomed
Nicolas Ramirez
@kamatheuska
Sep 19 2018 16:54
::forever alone::
:(
Xarri Jorge
@xarrijorge
Sep 19 2018 16:55
I'm on mobile so I'm no help bruh @kamatheuska
Nicolas Ramirez
@kamatheuska
Sep 19 2018 16:55
@xarrijorge its ok :( :(
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:56
@xarrijorge sure, sure , sure
Nicolas Ramirez
@kamatheuska
Sep 19 2018 16:58
@diomed you should help me man haha
have mercy for my soul
May Kittens Devour Your Soul
@diomed
Sep 19 2018 16:59
Nicolas Ramirez
@kamatheuska
Sep 19 2018 17:00
haha
that is an ugly rat man
May Kittens Devour Your Soul
@diomed
Sep 19 2018 17:00
that's a gopher
Nicolas Ramirez
@kamatheuska
Sep 19 2018 17:02
same thing
no? :D
I am not that good on animal terminology
May Kittens Devour Your Soul
@diomed
Sep 19 2018 17:03
gophers are Bill Murray's greatest enemies
Nicolas Ramirez
@kamatheuska
Sep 19 2018 17:05
yo, help me man hahahaha
I give you a hand with somethinfg else...I can send you some catfood
for example
I AM DESPERATE
haa
May Kittens Devour Your Soul
@diomed
Sep 19 2018 17:11
maby they can help you
Christopher McCormack
@cmccormack
Sep 19 2018 17:15
@kamatheuska have you done any unit testing, like passing in values to each function and validating the return is what you expect? I see no comments or logs in your code
Nicolas Ramirez
@kamatheuska
Sep 19 2018 17:22
sure, it is actually a FreeCodeCamp challenge, and this is a FCC gitter chat that says help. Here it is, already posted above: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register/
Kyle Holm
@thekholm80
Sep 19 2018 17:34
@diomed x
Augustas
@AugustasV
Sep 19 2018 17:36
Maybe someone can explain me, how I should write PHP code, and output everything as string? Something like that? I need to input some data, but output only in console or something
newmoon
@newmoon
Sep 19 2018 17:47
@AugustasV print, printF, or echo depending on your needs. Maybe start here: http://php.net/manual/en/function.print.php
Eric Weiss
@eweiss17
Sep 19 2018 17:55
oh php question? my time to shine

something like

echo "This is the output {$array['key']}";;

or if it is already a string,
echo "this is the variable $var";
to explicitly assign to string just use , $var (string) = [whatever];
Bjorn van de Peut
@bjorno43
Sep 19 2018 18:20
@AugustasV What do you mean with output in console? The browser console or actually a cli where you're running the PHP script? As PHP is server side..
Aditya
@ezioda004
Sep 19 2018 18:52

@kamatheuska That was a lot of code to go through: modified foo and count

let foo = cashInCurrency[1] > curTotal ? curTotal : cashInCurrency[1];
count = Math.floor((count - foo)*100)/100;

You'll notice penny is missing and thats because let curUnits = Math.floor(count / currencyNetWorth[curIndex])

I'm sure you can figure that one out
Nicolas Ramirez
@kamatheuska
Sep 19 2018 18:52
oh my god
I am tired to look at that function, but it is my last data structure challenge
thanks for the tip, but I need a beer right now. Will come back later to check it out!
@ezioda004
Augustas
@AugustasV
Sep 19 2018 18:56
@bjorno43 oh that made me think. I applying for PHP (e-commerce) internship, and they gave me task to write program in console who will have menu to add some entry's. I don't know why, but I thought I must do it in PHP :D In Javascript it will be easier for sure
Eric Weiss
@eweiss17
Sep 19 2018 19:03
@AugustasV PHP is server_side. Most happenings in PHP occur during a page load
Eric Weiss
@eweiss17
Sep 19 2018 19:10
if you need to add those entry's to a mySQL database... you may need to use php (or they expect you to)
Aditya
@ezioda004
Sep 19 2018 19:12
@kamatheuska Penny thing can be fixed with count = Math.ceil((count*100 - foo*100))/100;
And added .reverse() in { status: "CLOSED", change: cid.reverse() }
One last test is not passing which is for insufficient funds, you'll need to check the final cash with initial cash for that
On side note: 16.74 * 100 //1673.9999999999998
Thanks IEEE 754
Augustas
@AugustasV
Sep 19 2018 19:38
@eweiss17 mongodb also use php?
Niraj Nandish
@Nirajn2311
Sep 19 2018 19:50
@Smootimus Congrats on the 103%
Looks like TRUMP broke even the percentage system
Henry
@GitHub-Henry
Sep 19 2018 20:04
@kamatheuska perhaps check out https://gitter.im/FreeCodeCamp/LetsPair
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:06
@AugustasV Yes, mongodb can be used with PHP. Though it's more common to use MySQL with PHP
Kyle Holm
@thekholm80
Sep 19 2018 20:06
only the best
i've gotta use MySQL for a new project ... i'm not super excited
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:07
Meh. MySQL is pretty easy tbh
Kyle Holm
@thekholm80
Sep 19 2018 20:07
but sql in general is :fire: :poop:
Eric Weiss
@eweiss17
Sep 19 2018 20:08
yes yes, everything is trash
Kyle Holm
@thekholm80
Sep 19 2018 20:09
i agree lol
Wait.. Gitter no longer showing images?
Kyle Holm
@thekholm80
Sep 19 2018 20:10
nope
well, you can paste images directly
but hotlinks don't seem to preview
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:10
Pff
Kyle Holm
@thekholm80
Sep 19 2018 20:11
gitter is prejudiced against memes
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:11
what is markdown? for 200
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:11
A documentation language
Kyle Holm
@thekholm80
Sep 19 2018 20:11
a programming language, like html
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:11
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:13
@bobsbotty help
bobsbotty
@bobsbotty
Sep 19 2018 20:13
@bjorno43 D
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:13
Seriously..
psyperl
@psyperl
Sep 19 2018 20:13
is that go?
Kyle Holm
@thekholm80
Sep 19 2018 20:13
rofl
good bot
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:13
Ye I rly don't know why it's doing that..
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:14
yes, that's goooooooopher
Kyle Holm
@thekholm80
Sep 19 2018 20:14
maybe he's going through his terrible 2s
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:14
It has had enough of been used
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:14
I'm almost at the point where I'm like: screw that bot and trash it!
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:14
It wants to do something
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:14
is bob shakin' his booty often?
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:15
The fact that you're interested in that kinda worries me..
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:15
🀣🀣🀣
Well he's a cat, they have very different desires than us humans
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:15
:joy:
Kyle Holm
@thekholm80
Sep 19 2018 20:16
and he likes to watch
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:17
🀣
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:17
all :cat:s like to watch
gophers too
no, wait. gophers are blind by design I think
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:18
@diomed WHats with you gophers today
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:18
which makes me wonder why don't they draw it with glasses for blind, and a stick
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:19
Reminds me of that story where a woman identified as blind and poured chemicals into her eyes to realise it..
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:19
well, gotta be legally blind
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:20
Correction: She found a psychiatrist who was willing to help her and poured it into her eyes..
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:20
today I saw an Apple ad for guy who is legally blind photographer
man, all those blind people more successful than me
Smootimus
@Smootimus
Sep 19 2018 20:21
@Nirajn2311 Hahahaha
Broke it indeed
Thanks tho :D
I dunno if I said it here, but looks like my school switched
From teaching C++
To Python now, starting this next up coming quarter starting in a week or so
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:22
Nice
Smootimus
@Smootimus
Sep 19 2018 20:22
And it looks like I'll be helping with the material :D
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:22
CyX7o1nXAAUEV-W.jpg
The lies..
Smootimus
@Smootimus
Sep 19 2018 20:22
I was just asked
Oh those are big time lies
Kyle Holm
@thekholm80
Sep 19 2018 20:22
i wonder if the new iphone will be $2k?
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:22
Now it does more , but also costs more.
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:23
Costs less πŸ€”πŸ€”
psyperl
@psyperl
Sep 19 2018 20:23
it is costs less
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:23
Nah. Today it's Does less, costs more
psyperl
@psyperl
Sep 19 2018 20:23
nope costs less
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:23
@bjorno43 πŸ‘πŸ‘
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:23
O_o
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:24
Night folks
Bjorn van de Peut
@bjorno43
Sep 19 2018 20:24
Gn8 @Nirajn2311 :wave:
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:24
and @diomed be careful what you dream for
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:25
what do I dream for?
@Nirajn2311 did your weekend start today, or tomorrow night
psyperl
@psyperl
Sep 19 2018 20:25
but not many figured out how it costs less so less people buy it :D
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:26
Tomorrow night
But I’ll online from day after tomorrow
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:26
._o
Niraj Nandish
@Nirajn2311
Sep 19 2018 20:26
You dream of gophers
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:28
I got an archive layout task for you
May Kittens Devour Your Soul
@diomed
Sep 19 2018 20:39
o_.
psyperl
@psyperl
Sep 19 2018 21:08
:mushroom:
May Kittens Devour Your Soul
@diomed
Sep 19 2018 21:16
@psyperl we all know you're on shrooms most of the time
psyperl
@psyperl
Sep 19 2018 21:20
lol
Kyle Holm
@thekholm80
Sep 19 2018 21:20
i can't believe i didn't see that sooner
it makes so much sense
psyperl
@psyperl
Sep 19 2018 21:23
yums :smile:
May Kittens Devour Your Soul
@diomed
Sep 19 2018 21:27
:mask:
psyperl
@psyperl
Sep 19 2018 21:30
i want this shirt
Bjorn van de Peut
@bjorno43
Sep 19 2018 22:45
@thekholm80 Are you there?
Kyle Holm
@thekholm80
Sep 19 2018 22:48
yes sir
Bjorn van de Peut
@bjorno43
Sep 19 2018 22:49
You like books right?
Kyle Holm
@thekholm80
Sep 19 2018 22:49
most books
Bjorn van de Peut
@bjorno43
Sep 19 2018 22:49
Have you ever heard about "The Deathworlders"?
Kyle Holm
@thekholm80
Sep 19 2018 22:50
nope
Seriously, it got me hooked..
Kyle Holm
@thekholm80
Sep 19 2018 22:51
interesting. i'll give it a look