These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jan 2018
Muhammad Hasham
@MohammadHasham
Jan 20 2018 05:29
Can anyone help me with node.js?
Ken Haduch
@khaduch
Jan 20 2018 06:03
@MohammadHasham - you might want to ask a specific question or perhaps go and post in the HelpBackEnd room?
Muhammad Hasham
@MohammadHasham
Jan 20 2018 06:03
ok
Ken Haduch
@khaduch
Jan 20 2018 06:03
oops, I see that you did post there...
aRtoo
@artoodeeto
Jan 20 2018 06:04

hey fam! i have a question. how can you change the background when you toggle a button. ihave this css which toggle between toggle another class.

.isSwitchActive{
    margin: 0px 30px;
    transition-duration: 0.2s;
    background: green;
}

heres the pen.
https://codepen.io/artoo/pen/opQZWy

aRtoo
@artoodeeto
Jan 20 2018 06:41
tried installing babel any idea?
+ babel-core@6.26.0
updated 1 package in 0.962s
Raphaels-MacBook-Pro:~ raphaelgako$ npm install --babel-core
npm WARN saveError ENOENT: no such file or directory, open '/Users/raphaelgako/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/raphaelgako/package.json'
npm WARN raphaelgako No description
npm WARN raphaelgako No repository field.
npm WARN raphaelgako No README data
npm WARN raphaelgako No license field.

up to date in 0.292s
Raphaels-MacBook-Pro:~ raphaelgako$
Greg Duncan
@GregatGit
Jan 20 2018 06:47
@artoodeeto why do you need babel? For a react project or just some es6?
or are you just in codepen?
Long Nguyen
@longnt80
Jan 20 2018 06:49
where do I learn about drag and drop with javascript?
Greg Duncan
@GregatGit
Jan 20 2018 06:50
@longnt80 just google drag and drop with javascript
there is probably load of tutorials or just have a look on codepen at some of the examples
Long Nguyen
@longnt80
Jan 20 2018 06:59
most of them use the Drag and Drop API @GregatGit
aRtoo
@artoodeeto
Jan 20 2018 07:04
@GregatGit fo quokka.js bro
Pieter Stokkink
@forkerino
Jan 20 2018 09:46
@artoodeeto looks like you have to initialize the node project first: npm init
Pieter Stokkink
@forkerino
Jan 20 2018 10:08
@Masd925 how's the knee? Did you see a physician?
Matej BoĆĄnjak
@mbosnjak01
Jan 20 2018 10:11
I used to be an adventurer ... like you!
Razvan Jackson
@RazvanJackson
Jan 20 2018 10:55
Someone here good using Express and VueJS?
Christopher
@bradley1492
Jan 20 2018 12:01

Good Afternoon, I am currently working on the

https://www.freecodecamp.org/challenges/exact-change challenge.

Now my current problem is that, I don't know how I can go over the subarrays in cid-array, checking the subarrays for their actual denomination size, as I can't "read" the string "Penny" like I could check "0.01" instead of the word penny.

I want to do this, because my thought is that I then can go over the elements of the subarray and then use the remainder operator to determine if my current change sum can be divided by 0.

So I hope you guys understand my problem here. :)
I don't know if my thought is valid, but I can't think of another approach, maybe you guys have a tip here.

So basically I want to convert the strings describing the currency types to digits...

Pieter Stokkink
@forkerino
Jan 20 2018 12:04
@bradley1492 I'm not sure I entirely understand you, but usually the solution involves hardcoding the denomination sizes somewhere.
Naris R
@KittenHero
Jan 20 2018 12:05
yea, that's what I did too
Christopher
@bradley1492
Jan 20 2018 12:07

@forkerino Okay that's what felt so funny to me. Hardcoding being part of a challenge here.
So my hardcoding thought would basically be the following, I hope this makes sense:

Instead of ["Penny", 1.01]I would write [0.01, 1.01]?!
This is sort of the thought I had.

Is this kind of what you meant?

Pieter Stokkink
@forkerino
Jan 20 2018 12:08
@bradley1492 I created a separate array for it
Naris R
@KittenHero
Jan 20 2018 12:09
I used an object with the key as the name of the denomination
Pieter Stokkink
@forkerino
Jan 20 2018 12:09
i.e. var denominations = [0.01, 0.05, ... ] (in fact I did all calculations in pennies, because it takes care of some floating points problems.
@KittenHero I might have used an object as well
don't remember
but object is probably a little better.
Naris R
@KittenHero
Jan 20 2018 12:11
@forkerino yeah the floating point error is a bit troublesome
Christopher
@bradley1492
Jan 20 2018 12:12

@forkerino @KittenHero Okay the object makes sense, because I always wondered why they give me the hint of the global objectwhen everything is based on arrays.

Okay so because of the pennies you guys would write ` [1, 5, 10, 25 etc...]?!

Hmm I guess this leads me to my next thought of not knowing what to do with that array then... But I think I have to give myself some time to experiment a bit here before asking out again, if I can't manage to make progress :)

Pieter Stokkink
@forkerino
Jan 20 2018 12:14
@bradley1492 Hint: there is no need to always use the hints :)
Muhammad Hasham
@MohammadHasham
Jan 20 2018 13:26
is the .call() method in this example passing parameters to the Product function that are passed to Food, why are we not directly passing to the Product function.
function Product(name, price) {
  this.name = name;
  this.price = price;
}

function Food(name, price) {
  Product.call(this, name, price);
  this.category = 'food';
}
Naris R
@KittenHero
Jan 20 2018 13:28
oh that's the example from MDN
Muhammad Hasham
@MohammadHasham
Jan 20 2018 13:28
yeah!
Naris R
@KittenHero
Jan 20 2018 13:30
.call binds the this keyword of the function to the first argument
if that makes any sense at all
Muhammad Hasham
@MohammadHasham
Jan 20 2018 13:31
but can't we do like this
function Product(name,price){
 this.name = name;
 this.price = price;
}

new Product('anything',100);
@KittenHero
Naris R
@KittenHero
Jan 20 2018 13:32
yea, that would create a Product object
Muhammad Hasham
@MohammadHasham
Jan 20 2018 13:33
so why are we using .call then?
if we can do it simple like this?
what is the advantage/
Naris R
@KittenHero
Jan 20 2018 13:36
:/ you normally wouldn't use .call, but they used it in the Food function so when you call new Food(name, price) you get the object with the name, price and category = 'food'
not sure what to tell you other than that the example is really contrived
Muhammad Hasham
@MohammadHasham
Jan 20 2018 13:41
okay so we dont use .call much often?right?
@KittenHero thanks
CamperBot
@camperbot
Jan 20 2018 13:41
mohammadhasham sends brownie points to @kittenhero :sparkles: :thumbsup: :sparkles:
:cookie: 129 | @kittenhero |http://www.freecodecamp.org/kittenhero
Naris R
@KittenHero
Jan 20 2018 13:41
I've never used it personally, it's very js specific too
Christopher
@bradley1492
Jan 20 2018 14:03
@forkerino hahaha thanks, yes more often than not, the hint didn't align with my solution at the end, so one has to keep a balance here.
CamperBot
@camperbot
Jan 20 2018 14:03
bradley1492 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2970 | @forkerino |http://www.freecodecamp.org/forkerino
Markus Kiili
@Masd925
Jan 20 2018 16:11
@forkerino Yeah. Ligaments were not torn, so something else inside the knee maybe took some damage. I can walk quite normally, but cannot bend the knee all the way.
Naris R
@KittenHero
Jan 20 2018 16:12
arrow to the knee?
Markus Kiili
@Masd925
Jan 20 2018 16:13
@KittenHero Knee gave away when I was carrying another guy on my back.
Naris R
@KittenHero
Jan 20 2018 16:13
piggy back ride?
that sounds moderately fun
Danish Gujjar
@Dani-0-7
Jan 20 2018 18:28
image.png
Muhammad Hasham
@MohammadHasham
Jan 20 2018 19:03
i have seen process.nextTick() but i can't understand it.Can anyone tell me what it does in simple way.I know that it has to do something with eventloop
whats wrong ???
Pieter Stokkink
@forkerino
Jan 20 2018 19:42
@Dani-0-7 you miss a space before string
@Masd925 I'm hoping for the best!
Danish Gujjar
@Dani-0-7
Jan 20 2018 19:45
np tried
got it
Bryan Reese
@breese8009
Jan 20 2018 21:42
how do i embed a schema inside another one, but the shape of the embedded schema is different based on a 'type' property.
mongoose