These are chat archives for FreeCodeCamp/Help

6th
Nov 2018
Jacky Lui
@Recelis
Nov 06 2018 00:43
replied
Binyamin Aron Green
@b3u
Nov 06 2018 01:46
thanks
kinopotato
@kinopotato
Nov 06 2018 02:20

Hello, hoping for some quick clarification if anyone is available

function addTogether() {
  console.log(arguments)
  let a = [...arguments];
  console.log(a);

let b = a.every(function(n){
  if (isNaN(n)){
    return undefined;
  }
}) 
console.log(b); // returns false
}

addTogether(2, 3); // returns undefined

why is it returning undefined when the array IS a number?

abraham anak agung
@padunk
Nov 06 2018 02:24
@kinopotato your function didn't return anything.
kinopotato
@kinopotato
Nov 06 2018 02:24
holy crap how stupid can a human being get with this
my repl.it shows undefined so I thought it was returning the function
abraham anak agung
@padunk
Nov 06 2018 02:25
if a function didn't return anything, it will return undefined
kinopotato
@kinopotato
Nov 06 2018 02:26
god, I need jesus in my life. why do I keep forgetting the smallest of things
ehutchllew
@ehutchllew
Nov 06 2018 02:26
stuff like that will never stop happening
every now and then you'll forget a word or comma somewhere.
abraham anak agung
@padunk
Nov 06 2018 02:27
and a typo, which is sucks...
kinopotato
@kinopotato
Nov 06 2018 02:27
so being a dev is basically learning how to feel stupid a lot of times? xD
abraham anak agung
@padunk
Nov 06 2018 02:29
not really, when you make something working, you feel like...WHOA...I didt it... :laughing:
kinopotato
@kinopotato
Nov 06 2018 02:30
Yes, I remember doing fcc html/css certificate and having that feeling. I was like "I'm going to be a dev! this is real!" Oh naive naive boy
ehutchllew
@ehutchllew
Nov 06 2018 02:38
i periodically have imposter syndrome
like if at least twice a month i don't contemplate my incompetency as a dev, then it's not a normal month.
kinopotato
@kinopotato
Nov 06 2018 02:40
I don't get impostor syndrome, I've heard it used in multiple ways and now I don't even know what it really means. also, there's a difference between contemplating your incompetence twice a month which is actually good since it drives you to grow, compared to contemplating your incompetence every 5 minutes because you are actually incompetent xD
btw, is there a way to get isNaN to return true for stringy numbers? ie isNaN('3') true
Claudio Restifo
@Marmiz
Nov 06 2018 02:44

@kinopotato

btw, is there a way to get isNaN to return true for stringy numbers? ie isNaN('3') true

well, but that's false

also better use Number.isNan(), it's more robust that plain isNan(()
kinopotato
@kinopotato
Nov 06 2018 02:45
I can't get this stupid thing to work
let b = [];
b = a.every(function (n) {
  return typeof n == Number;
  });
console.log(b);
oh Number.isNaN
this returns false even when the argument is 2, 3
I'll try Number.isNan, but I really don't know why I'm having a hard time trying to compare elements to make sure it's a Number.
typeof is supposed to work, so I'm guessing there's something wrong with my syntax??
Claudio Restifo
@Marmiz
Nov 06 2018 02:47
@kinopotato typeof n === 'number'
kinopotato
@kinopotato
Nov 06 2018 02:48
@Marmiz that returns false no matter what I do :|
Claudio Restifo
@Marmiz
Nov 06 2018 02:48
unless you want to use the global object Number()
kinopotato
@kinopotato
Nov 06 2018 02:49
is my .every syntax wrong? I want it to return false if something is NOT a number
Claudio Restifo
@Marmiz
Nov 06 2018 02:49
@kinopotato you want to know if every member of an array is a number?
kinopotato
@kinopotato
Nov 06 2018 02:49
I've used typeof, Number.isNaN, isNaN all aren't working. which means I'm typing something wrong
yes
because if it isn't a number, I have to make it return undefined, if all are numbers then I want to get the sum
abraham anak agung
@padunk
Nov 06 2018 02:50
it should work with typeof, how you write it?
Claudio Restifo
@Marmiz
Nov 06 2018 02:50
@kinopotato every returns true for empty array. be mindful of that
kinopotato
@kinopotato
Nov 06 2018 02:51

function addTogether() {
  console.log(arguments)
  let a = [...arguments];
  console.log(a);

console.log(a.every(function(n){
  return typeof n === Number;
}));
let b = a.every(function (n) {
  return typeof n === Number;
  });
console.log(b);

}

addTogether(2, 3);
I've even logged it here just to see if something fishy is going on, but it returns false even though the parameters are 2 and 3, both are number
abraham anak agung
@padunk
Nov 06 2018 02:52
@kinopotato like @Marmiz said, typeof n === 'number'
Claudio Restifo
@Marmiz
Nov 06 2018 02:52
@kinopotato Number is not a type
kinopotato
@kinopotato
Nov 06 2018 02:52
fuck me
Claudio Restifo
@Marmiz
Nov 06 2018 02:53
kinopotato
@kinopotato
Nov 06 2018 02:54
how about if I were to use Number.isNaN?
Claudio Restifo
@Marmiz
Nov 06 2018 02:54

I mean, Number is a type, it's just that typeof returns another thing.

I know. JS types are fun!

@kinopotato look at the docs! :)
that's how you learn
kinopotato
@kinopotato
Nov 06 2018 02:55

I changed this to Number.isNaN,

function addTogether() {
  console.log(arguments)
  let a = [...arguments];
  console.log(a);

console.log(a.every(function(n){
  return typeof n === Number;
}));
let b = a.every(function (n) {
  return Number.isNaN(n);
  });
console.log(b);

}

addTogether(2, 3);

if I do the Number.isNaN alone, it works for "3" returning false and 3 returning true but when I use it this way, it returns false always.

Claudio Restifo
@Marmiz
Nov 06 2018 02:55
then ask for any further questions :)
kinopotato
@kinopotato
Nov 06 2018 02:55
@Marmiz I'm actually intimidated by MDM, I don't know why
Claudio Restifo
@Marmiz
Nov 06 2018 02:55
@kinopotato well, time to get over it
kinopotato
@kinopotato
Nov 06 2018 02:56
it's like I can but can't understand it? it sounds weird right?
I mean I read it, I just can't get it? does that make sense?
You're right though, I'm probably not doing enough
Claudio Restifo
@Marmiz
Nov 06 2018 02:56

heads over and see MDN docs for Number.isNan. You should know why

Number.isNan(2)

return false. if not, then we can help you out

kinopotato
@kinopotato
Nov 06 2018 02:57
you're right, I'll go do that now.
so Number() converts things into numerical value, thus "3" is still a number even if it's a string
b3twiise
@b3twiise
Nov 06 2018 03:06
My guess is Number is a class with methods. Then isNan method simlpy checks that arg is nan. So gives result as boulean
Doc will say it better
short read actually
kinopotato
@kinopotato
Nov 06 2018 03:09
I'm reading that actually, it seemed weird because Number.isNaN returns true if the object is NaN AND is a Number which sounded strange. so I read Number and it said this "If the argument cannot be converted into a number, it returns NaN." so I'm assuming "3" is converted or is read as a Number due to == or something like that
there's still a lot of gap in how I understand it though
b3twiise
@b3twiise
Nov 06 2018 03:13
"the passed value is NaN and its type is Number"
meitram
@meitram
Nov 06 2018 03:13
NaN is a Number in javascript
check typeof NaN;
b3twiise
@b3twiise
Nov 06 2018 03:15
so from my understanding, you get true only if arg is NaN
both booleans must hold true
from doc " This also means that only values of the type number, that are also NaN, return true."
Claudio Restifo
@Marmiz
Nov 06 2018 03:24
@kinopotato Number.isNan returns true if the value is both Nan and a Number "type".
2 definitely is not NotANumber. Is A number
Nan is a type by itself.
2 !== Nan
kinopotato
@kinopotato
Nov 06 2018 03:29
typeof NaN returns "number" xD I don't even know what to think of that
I need to read more books about JS
right now I'm trying to finish FCC JS then read books since I'm thinking after FCC I'll definitely get a really good overview to make more sense of whatever I read
b3twiise
@b3twiise
Nov 06 2018 03:37
I love big books and I cant even lie
meitram
@meitram
Nov 06 2018 03:41
"Nan is a type by itself."
No.
b3twiise
@b3twiise
Nov 06 2018 03:42
Number
Claudio Restifo
@Marmiz
Nov 06 2018 04:15

@b3twiise it's both part of Number global object and a global object by itself.
for sake of simplicity I said that since Nan is a type by itself since it cannot be compared.

in hope to make it easier to understand

b3twiise
@b3twiise
Nov 06 2018 04:20
the js fun stuff. Thanks @Marmiz
Where is @codebot? lol
Claudio Restifo
@Marmiz
Nov 06 2018 04:24
Nan is actually complex for every language, since it's the result of a mathematical operation.
In C you find it defined in the math.h library, and I think it's a double type? (not sure if this is c or cpp)
b3twiise
@b3twiise
Nov 06 2018 04:33
yupp, seems like you are right. both nan and infinity are floats available in math.h
Laurent Harel
@Lornz-
Nov 06 2018 04:48

Hi there!

Did anyone have encountered this issue in their FCC profile before? I can’t access any of my certification right now.
👉 freeCodeCamp/freeCodeCamp#34154

Anand Potukuchi
@anandpotukchi
Nov 06 2018 05:47
Ahmm'
andrea
@girlcodecrush
Nov 06 2018 06:38
@fmartin5 correct! for the filter method, for loop is not necessary. It was a mistake - habituallyl, if it is an array and iteration is required, I put for -loop. Based on your advise, and some further corrections,..(haha) now I have the final code for filtering function as shown below: request(options, (error, response, body) => {
if (!error && response.statusCode === 200) {
var naverNews = JSON.parse(body).items.filter(item => {
if (item.link.split('/')[2] === 'news.naver.com') {
return item;
}
});
// console.log('33333#####', naverNews);
  var titleLink = naverNews.map(item => {
    return { title: item.title, link: item.link };
  });
//  console.log('$$$$$$$$$$$$', titleLink);
  res.set({ 'content-type': 'application/json; charset=utf-8' }); // should set utf-8 in request as well!!
  res.send(titleLink);                                                                                                                                                        sorry for late reply and thanks! 
andrea
@girlcodecrush
Nov 06 2018 07:01

@anandpotukchi hi Anand. The library used is react-responsive-audio-player. Basically, what to do/achieve is play each news article when the users clicks on the headline of news articles on the list. There is an audio player, but instead of pressing the play button, i want each article to be played when the onclick event happens to the headline. Users can stop playing on the player if they want. Unfortunately, against my hope, when testing it out, it didn’t go the way I thought. To listen, I had to click the headline and click the audio play button so needed to click twice for listening. Have you ever handled audio play function by clicking the text(here, the news headline on the list)? If so, please do kindly share. This is gonna be the main function of the website. Below is the code for audio: givePlaylistInfo = (clickedArticle) => {
const fetchPlaylist = this.props.fetchPlaylist
fetchPlaylist(clickedArticle)
}

render() {
let displayArticles = this.props.articles.map((article, index) => {
console.log("article", article)
return (
<div>
<div data-index={index} className='card bg-light mb-2' key={index} onClick={() => this.givePlaylistInfo(article)}>

          <div className='card-body'>
          <div><img src={article.image_url} alt=''></img></div>
          <span className='text-muted'>#{article.rank}</span>
          <h5 className='card-title'>{article.title} <span className='text-muted'>{article.publisher}</span></h5>
          </div>

          <audio preload='none' controls >
          <source src={`http://13.125.111.99/play?url=${article.source_url}`} type="audio/mp3"/>
          </audio>

        </div>
      </div>
      )})
      return (
        <div>
          {displayArticles}
        </div>
      )

}
}

Claudio Restifo
@Marmiz
Nov 06 2018 07:42
@girlcodecrush you can use the native JS MediaElement.play()
andrea
@girlcodecrush
Nov 06 2018 07:44
Hi. Claudio. Can i use it in create-react-app?
Claudio Restifo
@Marmiz
Nov 06 2018 07:45
For sure. It's just plain JS.
React support also media events as well.
https://reactjs.org/docs/events.html#media-events
andrea
@girlcodecrush
Nov 06 2018 07:46
@Marmiz alright. will refer to it. Thanks
Claudio Restifo
@Marmiz
Nov 06 2018 07:49
by the look of it, you are using DOM audio elements.
You can simple attach a ref to it, then onClick of the header get the DOM node and play() it
zhangjunjie02
@zhangjunjie02
Nov 06 2018 07:59
<img class="smaller-image" class="thick-green-border" src="/images/relaxing-cat.jpg">
这段代码有啥错误
.thick-green-border{
border-color: green;
border-width: 10px;
border-style: solid;
}
Victor Popescu
@VicPopescu
Nov 06 2018 08:05
@zhangjunjie02 don't use 2 instances of the classattribute
@zhangjunjie02 class="smaller-image" class="thick-green-border" should be class="smaller-image thick-green-border
kinopotato
@kinopotato
Nov 06 2018 08:12
hello people, just wanted to hear some insight. I've been learning JS for about a month and a half now, is it normal that I still find it hard to code solutions for FCC challenges like this?
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional
I've been studying full time too, but not much during weekends
hensn5250
@hensn5250
Nov 06 2018 08:12
yes , it is normal. javascript is very quirky even for those that know other languages since it does not follow conventional Object Oriented Programming and has other unconventional behaviors.
kinopotato
@kinopotato
Nov 06 2018 08:13
so I'm doing something very wrong then
oh, it is?
maybe I should've started with PHP xD too late now
hensn5250
@hensn5250
Nov 06 2018 08:16
The big thing you should do first is know what the challenges is asking you to do.
Sometimes the way the word the challenges can be confusing.
kinopotato
@kinopotato
Nov 06 2018 08:18
Yes, I agree. Even with that challenge I was trying to do a code that will work with x amount of arguments when in reality, FCC only wanted two.
hensn5250
@hensn5250
Nov 06 2018 08:19
What is your interpretation of the challenge?
kinopotato
@kinopotato
Nov 06 2018 08:19
at first I thought it was just check if the parameters are numbers, if yes, sum, if not, return undefined. it was wrong though, I didn't realize til' late I was supposed to curry
hensn5250
@hensn5250
Nov 06 2018 08:22
right If only one argument is provided, then return a function that expects one argument and returns the sum. That statement was confusing to me as well
kinopotato
@kinopotato
Nov 06 2018 08:24
now I have to do currying, or is crying? hahaha. this is fun though, it's been a while since I've really tried giving my best at something
hensn5250
@hensn5250
Nov 06 2018 08:27
good for you. its like riding a bike. At first it seems foreign but once you've get over a certain threshold it becomes second nature
kinopotato
@kinopotato
Nov 06 2018 08:29
I'm hoping that happens soon, lol
zhangjunjie02
@zhangjunjie02
Nov 06 2018 09:01

<h2 class="red-text">CatPhotoApp</h2>
<!-- 请只修改这条注释以下的代码 -->

<p>View more <a href="https://freecodecamp.cn">cat photos</a></p>

<a href="http://www.freecatphotoapp.com">cat photos</a>

这段代码有什么错
把你的a元素嵌套进一个新的p元素(紧邻已有的h2元素之后),让段落的文本为View more cat photos,但是其中仅cat photos是一个链接,其余的是普通文本。
任务是
May Kittens Devour Your Soul
@diomed
Nov 06 2018 09:04
May Kittens Devour Your Soul
@diomed
Nov 06 2018 09:41
oh darn! I forgot 5th of November
yikes!
Anand Potukuchi
@anandpotukchi
Nov 06 2018 09:47
const reducer = (state, action) => {
    switch(action.type) {
        case "ADD":
        state = state + action.payload;
        break;
        case "SUBTRACT":
        break;
    }

    return state;
};
Error: Expected the reducer to be a function.
May Kittens Devour Your Soul
@diomed
Nov 06 2018 09:48
@anandpotukchi Sierra Burges is a loser
Anand Potukuchi
@anandpotukchi
Nov 06 2018 09:48
@diomed i really think she's cute
so not a loser
Ene Catalin
@EneCatalin
Nov 06 2018 09:49
she could be a cute loser
and since truth is always in the middle she must be
Anand Potukuchi
@anandpotukchi
Nov 06 2018 09:49

oops

I meant I think shes's really cute

@EneCatalin did you wantch the movie
Ene Catalin
@EneCatalin
Nov 06 2018 09:50
what movie ?
are there boobs in it ?
Anand Potukuchi
@anandpotukchi
Nov 06 2018 09:50
@EneCatalin Sierra Burges is a loser
Ene Catalin
@EneCatalin
Nov 06 2018 09:50
wait that's the name of a movie
lol
Anand Potukuchi
@anandpotukchi
Nov 06 2018 09:51
@EneCatalin not sure
May Kittens Devour Your Soul
@diomed
Nov 06 2018 09:51
it is
Anand Potukuchi
@anandpotukchi
Nov 06 2018 09:51
yeah it is
@EneCatalin not sure about the boobs
name of a amove yes
May Kittens Devour Your Soul
@diomed
Nov 06 2018 10:39
where in the world is Carmen Sandiego?
Anand Potukuchi
@anandpotukchi
Nov 06 2018 12:03
I am an idiot
Didn;t pass params into the store
Sheldon Li
@Assassin0015
Nov 06 2018 13:08
So,what is "元素选择器" ???
Niraj Nandish
@Nirajn2311
Nov 06 2018 13:10
Where in the world is @diomed
Luc Martin
@fmartin5
Nov 06 2018 15:24
@kinopotato Yeah it's difficult to phrase what the challenge wants
I tried to reword it like this:
If addTogether gets two args then it should return their sum.
But if addTogether gets just one arg (say arg1),
then it should return a new function of one arg (say arg2),
and this function should return the sum of arg1 and its own argument (e.g. arg1 + arg2).
Luc Martin
@fmartin5
Nov 06 2018 15:35
So if you don't pass addTogether enough args to compute the sum, it will return another function which "knows" what args were already passed in
Instead of incorrectly adding arg1 to undefined
Luc Martin
@fmartin5
Nov 06 2018 16:13
@kinopotato As for NaN, although it doesn't encode a "real-world" number, it is nonetheless a JS number, albeit a "special" one like Infinity and -Infinity
Niraj Nandish
@Nirajn2311
Nov 06 2018 16:14
@fmartin5 which challenge
Niraj Nandish
@Nirajn2311
Nov 06 2018 16:17
Isnt that like nested functions
Luc Martin
@fmartin5
Nov 06 2018 16:17
Well the returned function is a closure
Niraj Nandish
@Nirajn2311
Nov 06 2018 16:18
Yeah
Luc Martin
@fmartin5
Nov 06 2018 16:18
It's a nested function that you return ^^
Instead of using it straight away
Diogo Esteves
@EstevesDiogo
Nov 06 2018 16:24
hi guys
can any one help me with this :
when i use NGRX i have to use services to or can i remove them completely??
May Kittens Devour Your Soul
@diomed
Nov 06 2018 16:44
@Nirajn2311 I'm in Croatia. lol :ghost:
@EstevesDiogo I have 28 years old
computer says no
Luc Martin
@fmartin5
Nov 06 2018 16:57
Never heard of NGRX sorry :/ @EstevesDiogo
Diogo Esteves
@EstevesDiogo
Nov 06 2018 16:58
@fmartin5 ok thnk you any way :P
Sumit Basra
@sumitbasra
Nov 06 2018 17:04
How do we find out about the local meetups and hackathons in SF?
Aditya
@ezioda004
Nov 06 2018 17:06
meetup.com
glitz20
@glitz20
Nov 06 2018 17:17
is there good api/library for survey for react+node.js?
which is a good one?
Niraj Nandish
@Nirajn2311
Nov 06 2018 17:50
@diomed Hey :cat:, how's it goin'
coding91
@coding91
Nov 06 2018 18:54
Hi Folks,
Can anyone suggest me good site for learning node.js
May Kittens Devour Your Soul
@diomed
Nov 06 2018 19:00
@Nirajn2311 oh you know - lost in space and time
and vue
May Kittens Devour Your Soul
@diomed
Nov 06 2018 19:28
@Nirajn2311 what'cha doing these days?
Eric Miller
@ericmiller777
Nov 06 2018 19:33
@xarrijorge thank you
Mohammed Nabeel
@mnabeelp
Nov 06 2018 19:51
Can anyone suggest a site for nose.js?
Luc Martin
@fmartin5
Nov 06 2018 19:53
Vanilla node.js ?
May Kittens Devour Your Soul
@diomed
Nov 06 2018 19:53
pinokio.js
Mohammed Nabeel
@mnabeelp
Nov 06 2018 19:54
@@
@diomed thanks
Eric Weiss
@eweiss17
Nov 06 2018 20:17
is nose.js a real thing?
May Kittens Devour Your Soul
@diomed
Nov 06 2018 20:36
of course it is.
even nosehair.js is a real thing
❣️ real stuff ❣️
Mohammed Nabeel
@mnabeelp
Nov 06 2018 20:51
Node.js
Xarri Jorge
@xarrijorge
Nov 06 2018 21:29
pinokio.js :laughing: :laughing: @diomed
There doesn't seem to be any nodejs docs out there with real context. Its a shame.
7761cookie
@7761cookie
Nov 06 2018 22:01
image.png
Hey, anyone know how to align the form elements?
Trying to do it without a grid
Jason Luboff
@JLuboff
Nov 06 2018 22:03
It does look like they
re using two columns with right align on the left column, and left align on the right column
7761cookie
@7761cookie
Nov 06 2018 22:04
i think i need to display: inline-block; and wrap the html elements by name?
then set the text-align: right; and text-align: left;
May Kittens Devour Your Soul
@diomed
Nov 06 2018 22:06
you can either post a pen or try
what do we know. we dont see your code
7761cookie
@7761cookie
Nov 06 2018 22:11
May Kittens Devour Your Soul
@diomed
Nov 06 2018 22:14
would be best if you wrapped all those labels & inputs in a div and give it some mad margin
7761cookie
@7761cookie
Nov 06 2018 22:21
yeah, so i could add a class from css called left-container and right-container and set the css in them to reflect the output required then add the class attributes to the corresponding html elements?
7761cookie
@7761cookie
Nov 06 2018 22:58
So I have got about 70% done but getting some issues with radios and checkboxes: https://codepen.io/anon/pen/NEGaGY
7761cookie
@7761cookie
Nov 06 2018 23:19
Any ideas on how to position them correctly?
Sean Kelly
@spkellydev
Nov 06 2018 23:35
anyone kknow any opensource projects looking for contributors