These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Apr 2018
DistinctWolf
@DistinctWolf
Apr 04 2018 01:38
I need help with content security policy, I have this in the meta tag in the head of the html, the css files loads and it's linked to the html file but for some reason styles don't apply to the html elements
<meta http-equiv="Content-Security-Policy" content="style-src 'self' http://fonts.googleapis.com; font-src 'self' data: https://fonts.gstatic.com;">
fonts work fine but the css file don't get linked with the html file
May Kittens Devour Your Soul
@diomed
Apr 04 2018 10:27
ndburrus bot alert
Christopher
@bradley1492
Apr 04 2018 11:09

Hello,

I just work on a little script to solve the Exact Change challenge.
Why is change logging out -10 here and not 0?
My while loop should stop adding numbers to change as soon as change has arrived at 0....
Do you guys know what's wrong here?

https://jsfiddle.net/7szxxmxz/9/

Leigh Hobson
@leighhobson89
Apr 04 2018 11:14
hi guys, why is this loop infinite? i think it is something to do with [i+1] not evaluating properly but I'm not sure...
function sumFibs(num) {

  var arrFib = [1,1];
  var fibonacci = 2;

  for (var i=0;i<arrFib.length;i++) {
    if (i>0) {
      fibonacci += arrFib[i+1];
    }
    console.log(fibonacci);
    if (fibonacci > num) {
      break;
    }
    if (fibonacci % 2 != 0) {
      arrFib.push(fibonacci);
    }
  }
  num = arrFib.reduce(function(total,num) {return total+num;});
  return num;
}
Markus Kiili
@Masd925
Apr 04 2018 11:14
@bradley1492 Console.log what coins are being used, and you will see the problem with the logic.
Leigh Hobson
@leighhobson89
Apr 04 2018 11:17
i realise its because nothing is pushed to the array on the first pass so there is no [i+1] to add! I wasnt thinking 4th dimensionally lol
and while i was at it i need [i] not [i+1] doh!
Christopher
@bradley1492
Apr 04 2018 11:21
@Masd925 hmm now I had a look at the logged numbers. I think my logic has a flaw here. Because for example with a change amount of 30. If I have one 20 dollar bill.
30 can't be divided by 20 without rest but still 20 would be an approriate denomination here...
Stephen James
@sjames1958gm
Apr 04 2018 11:30
@leighhobson89 There is no good reason to create the array as you have each individual value in the first loop
where you can sum them right there.
Leigh Hobson
@leighhobson89
Apr 04 2018 11:32
@sjames1958gm it works now, but im all ears, so what, just set arrFib = []; ?
my classic overlong codes strike again:
function sumFibs(num) {

  var arrFib = [1,1];
  var fibonacci = 2;

  for (var i=0;i<arrFib.length;i++) {
    if (i>0) {
      fibonacci += arrFib[i];
    }
    if (fibonacci > num) {
      break;
    }
    arrFib.push(fibonacci);
  }
  for (i in arrFib) {
    if (arrFib[i] % 2 == 0) {
      arrFib.splice(i,1);
    }
  }
  num = arrFib.reduce(function(total,num) {return total+num;});
  return num;
}
Stephen James
@sjames1958gm
Apr 04 2018 11:37
@leighhobson89 You only need the last two values so
compute the sum and the fibonacci in one loop
// start sum = 0;
// if fibonacci is odd add to sum
arr[0] = arr[1];
arr[1] = fibonacci
fibonacci = arr[0] + arr[1];
Leigh Hobson
@leighhobson89
Apr 04 2018 11:38
ahh im with you. cheers @sjames1958gm
thanks @sjames1958gm
CamperBot
@camperbot
Apr 04 2018 11:38
leighhobson89 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9162 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Apr 04 2018 11:40
@leighhobson89 :+1:
christie92
@christie92
Apr 04 2018 11:43
@sjames1958gm can you help me with my js code pls?
Stephen James
@sjames1958gm
Apr 04 2018 11:44
@christie92 What is the issue?
christie92
@christie92
Apr 04 2018 11:45
@sjames1958gm i can't understand why it isn/t working https://codepen.io/ChristieGreys/pen/wmyvwa
Stephen James
@sjames1958gm
Apr 04 2018 11:46
How is it "not working". What behavior is wrong or missing?
christie92
@christie92
Apr 04 2018 11:47
@sjames1958gm does not functions the countdown , it isn't begining
i think i have any issue in the linking HTML+JS , i think
Stephen James
@sjames1958gm
Apr 04 2018 11:48
@christie92 Did you check your dev tools console - there is an error there
christie92
@christie92
Apr 04 2018 11:48
yes i checked for html css and js but non an issue
still not running
Stephen James
@sjames1958gm
Apr 04 2018 11:49
@christie92 It is running but there is no element with the id of demo
christie92
@christie92
Apr 04 2018 11:50
but when i put the <p id="demo"> in html it showed NaN
NaNd NaNh NaNm NaNs
Stephen James
@sjames1958gm
Apr 04 2018 11:51
@christie92 var distance=countDownDate-now; I did a console.log on distance and it is NaN
You need to figure out a better way to get distance from two Date objects
christie92
@christie92
Apr 04 2018 11:52
@sjames1958gm ok thank you
CamperBot
@camperbot
Apr 04 2018 11:52
christie92 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9163 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Josh Queen
@josh-queen
Apr 04 2018 12:00
Hi guys, new to the room (and JS in general)
I'm working on the return the largest number in an array challenge and can't figure out why my code isn't working
Markus Kiili
@Masd925
Apr 04 2018 12:01
@Kohota107 Welcome!
Josh Queen
@josh-queen
Apr 04 2018 12:01
Thanks!
function largestOfFour(arr) {
  var resultArr = arr.map(function(val){
    return Math.max(val);
  });
  return resultArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
I'm just getting null values returned
Markus Kiili
@Masd925
Apr 04 2018 12:03
@Kohota107 Math.max doesn't work on arrays of numbers just like that.
You can make it work with some JS magic.
Math.max.apply(null,[1,4,2,8,3]); // 8
Josh Queen
@josh-queen
Apr 04 2018 12:05
Ahh, perfect
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 12:06
@Kohota107 either what @Masd925 said or return Math.max(...val);
Josh Queen
@josh-queen
Apr 04 2018 12:06
so Math.max.apply(null, val); works
@SweetCodingInc what does the ... represent in js?
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 12:07
@Kohota107 It's called spread operator.
It will take an array spread it's values as parameters to .max
it gives you similar output as max.apply(null, val)
Josh Queen
@josh-queen
Apr 04 2018 12:08
Ahh, perfect
Thanks both!
Danny Chan
@chandanny
Apr 04 2018 14:36
hello
Stephen James
@sjames1958gm
Apr 04 2018 14:52
@chandanny :wave:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 14:53
hello scripters
Stephen James
@sjames1958gm
Apr 04 2018 14:53
@RoniqueRicketts :wave:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 14:53
I have an UNEXPECTED FEATURE in my personal react program and I need some help
@sjames1958gm sup bruv
Stephen James
@sjames1958gm
Apr 04 2018 14:54
@RoniqueRicketts Fightin' the "good" fight.
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 14:55
how take remainder of 11 / 3 ?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 14:55
Good man. Its beating me
The good fight is beating me.
Aniculaesei
@Aniculaesei
Apr 04 2018 14:59
Hi guys!Can you help me with some code please?Thank you
  let squaredIntegers = arr.filter(x => x % 2 == 0&& x > 0);
   squaredIntegers = arr.map(y =>y*y);
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:00
@sjames1958gm how can I share my screen with you so you can see whats going on with my code
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:01
@Aniculaesei What are you trying to do?
Aniculaesei
@Aniculaesei
Apr 04 2018 15:02
Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray and store the new array in the variable squaredIntegers.
:)
Daniel Simeonov
@dbsimeonov
Apr 04 2018 15:02
@RoniqueRicketts You either can make a screenshot and upload it to imgbb or share a codepen
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:04
@sjames1958gm can u join me and help me out
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 15:05
export const authenticateUser = (credentials, chai, server) => {
    return new Promise(async (resolve, reject) => {
        try {
            let res = await chai.request(server)
                .post("/user/login")
                .send(credentials);
            resolve(res.headers["set-cookie"]);
        } catch (e) {
            reject(e);
        }
    })
}
describe("#User", () => {
    before(async () => {
        try {
            cookie = await authenticateUser(adminCredentials, chai, server);
        } catch (e) {
            console.log(e);
        }
    });

    describe("USER/REGISTER", () => {
        it("should register the user", (done) => {
            chai.request(server)
                .post("/user/register")
                .send(userCredentials)
                .set("Cookie", cookie)
                .end((err, res) => {
                    res.should.have.status(200);
                    res.should.be.json;
                    res.body.should.be.a("object");
                    res.body.should.have.property("email")
                    res.body.should.have.property("name")
                    res.body.should.have.property("isActive")
                    res.body.should.have.property("permissions")
                    res.body.should.have.property("definePasswordLink")
                    res.body.should.have.property("firstLink")
                    done();
                });
        });
    });
})
image.png
anyidea what's wrong?
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:06
@Aniculaesei You need to do %1 instead of %2
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:07
help me~ how to take the remainder with 11 divide 3 ?
Jason Luboff
@JLuboff
Apr 04 2018 15:08
@DerrickHsiao You use remainder (aka Modulo) the same way you would division except that instead of getting the divided result, you get the remainder so
let result = 15 % 2 //the result is 1
@tiagocorreiaalmeida Why using async and promise? (Full disclosure, I have no experience with async)
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:11
@Aniculaesei
var arr = [1,-5, 2.3, 5];

let squaredIntegers = arr.filter(x => x % 1 == 0&& x > 0);

console.log(squaredIntegers); // [1, 5]
squaredIntegers = squaredIntegers.map(y =>y*y);
console.log(squaredIntegers); // [1, 25]
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:13
I know but I can't pass the topic of 146.........why.....
Jason Luboff
@JLuboff
Apr 04 2018 15:13
@DerrickHsiao Show your code
Btw, challenges have names, not numbers :D
Aniculaesei
@Aniculaesei
Apr 04 2018 15:13
@SweetCodingInc Thank you
CamperBot
@camperbot
Apr 04 2018 15:13
aniculaesei sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 402 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Aniculaesei
@Aniculaesei
Apr 04 2018 15:14
i was using other arr :))
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:14
@Aniculaesei yes.. and %2 instead of %1
Aniculaesei
@Aniculaesei
Apr 04 2018 15:14
@SweetCodingInc can you tell me please why x%1 ==0 :)
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:15
I see, the name is [Finding a Remainder in JavaScript]
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:15
%2 will give you either 1 or 0 depending on the whether the number is even or odd
you want to find out number that are fractions.
and any integer when divided by 1, gives you 0
if it's anything other than 0, it's not an integer :)
@Aniculaesei
Coalited
@Coalited
Apr 04 2018 15:16

Stuck on this problem for a while now, looking to see if anyone can provide me with an elegant solution !
Considering these three arrays:

var arrayA = [a, b]
var arrayB = [a]
var arrayC = [[a, b], [a], [a, b, c], [c], [a, b,]]

How can I perform a search on arrayC with arrays A and B respectively?
My expected output when performing a search on arrayC with arrayA is: [[a, b], [a, b]]
And when performing a search on arrayC with arrayB: [[a, b], [a], [a, b, c], [a, b]]

Aniculaesei
@Aniculaesei
Apr 04 2018 15:16
@SweetCodingInc i understand now..in this way i find out if a number is an integer :)
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 15:16
cause the function itself needs to return a promise but I also need to wait for the mongo promise to resolve/reject
Aniculaesei
@Aniculaesei
Apr 04 2018 15:17
@SweetCodingInc I own you a cofee :)
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:19
@Aniculaesei :+1: :laughing:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:19
@JLuboff boss!!!
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:19
@tiagocorreiaalmeida :wave:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:19
how is your REACTJS and CSS?
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:19
how you doin mate? No more codefights?
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:20
I'm come from Taiwan
The Chinese freeCodeCamp have strange chinese translation
I can't undersdent about some challenges......
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:20
I need some help with a little react app. I need help with the css aspect of it. I am getting an Unexpected Feature
Jason Luboff
@JLuboff
Apr 04 2018 15:20
@RoniqueRicketts No react experience, garbage at css lol (I tend to use frameworks either Bootstrap or Bulma)
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:20
@JLuboff how dare you!!!!
Jason Luboff
@JLuboff
Apr 04 2018 15:20
@DerrickHsiao No worries. Can you show the code you have tried?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:20
:'(
Jason Luboff
@JLuboff
Apr 04 2018 15:20
@RoniqueRicketts I just haven
't taken the time to learn all that I need to
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:21
Who can help the nerd?
Jason Luboff
@JLuboff
Apr 04 2018 15:21
only becuase I have way too much other shit going on lol
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:21
@JLuboff How do I show my code?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:21
NERD DOWN! NERD IN DISTRESS!!!!
Jason Luboff
@JLuboff
Apr 04 2018 15:22
@DerrickHsiao You can just copy and paste it. Ideally, you would format it by placing three backticks, go to the next line, paste code, go to next line and three more backticks like so:
```
shift+enter for new line, paste code, shift+enter for new line
```
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:22
@sjames1958gm where are you??
Jason Luboff
@JLuboff
Apr 04 2018 15:23
He is probably working :D
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:23
@JLuboff thats lazy fool works???? :O
hehehe i figure he'd be at work.
Jason Luboff
@JLuboff
Apr 04 2018 15:23
Ya he doesn't get as much time on the chat now
I think he secretly is staying away as to not get to 10,000 brownies too quickly :joy:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:24
Ya I guess his manager is over his shoulder making sure he is not on FCC :)
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 15:24
@SweetCodingInc hey, theres always time for some codefights :smile:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:24
@JLuboff Oh so that's his plan
@tiagocorreiaalmeida TIAGO my pal, how are you today?
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:25
@JLuboff
// 请只修改这条注释以下的代码

var remainder;
@JLuboff ........................
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:26
@tiagocorreiaalmeida the one @JLuboff was just calling your name saying that you can't even write code in React. I told him you could and he was laughing at you. Do you want to prove him wrong.
Jason Luboff
@JLuboff
Apr 04 2018 15:26

@DerrickHsiao Ok, so you need to assign the expression 11 % 3 to the variable remainder

var myNum = 15 % 3;

In my example here, I have assigned the expression 15 % 3 to the variable myNum

Kudzu
@czhower
Apr 04 2018 15:28
You havent assigned the expression, you have assigned the result of the expression.
It might seem a small difference, but in the coding world, especially JS, its a big distinction.
Jason Luboff
@JLuboff
Apr 04 2018 15:29
@czhower Fair enough, my verbage is not always the best ;)
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:29
How easy!! I'm feel stupid right now :worried:
Jason Luboff
@JLuboff
Apr 04 2018 15:30
@DerrickHsiao Don't feel stupid, many people get stuck on that challenge
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:31
@DerrickHsiao don't man, just keep going. The more you do the more you learn.
@JLuboff Do you wish to waste 15m checking out some React code?
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:31
@JLuboff Thank a lot
CamperBot
@camperbot
Apr 04 2018 15:31
derrickhsiao sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2391 | @jluboff |http://www.freecodecamp.org/jluboff
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 15:32
@RoniqueRicketts sure! I ready for learn more coding skill!
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:33
@DerrickHsiao are you good at react?
Aniculaesei
@Aniculaesei
Apr 04 2018 15:35
@SweetCodingInc are you still here? :D
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:37
@Aniculaesei Yo!
Aniculaesei
@Aniculaesei
Apr 04 2018 15:37
Can you explain me something more?Just a little thing :)@SweetCodingInc
const sum = (function() {
  "use strict";
  return function sum(...args) {
    return args.reduce((a, b) => a + b, 0);
  };
})();
console.log(sum(1, 2, 3)); // 6
From where is that 0?(after a+b)
:)
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:39
In React CLI does .css files sync across components?
Kaz Baig
@kbaig
Apr 04 2018 15:40
@RoniqueRicketts what do you mean by syncing across components sorry
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:41
@Aniculaesei sure.. waht do youwanna know?
Aniculaesei
@Aniculaesei
Apr 04 2018 15:41
const sum = (function() {
  "use strict";
  return function sum(...args) {
    return args.reduce((a, b) => a + b, 0);
  };
})();
console.log(sum(1, 2, 3)); // 6
from where is that 0 after a+b?
:)
Kaz Baig
@kbaig
Apr 04 2018 15:41
@Aniculaesei it's the second arg to reduce, which is the initial value of the accumulator
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:41
@Aniculaesei That's a syntax for the .reduce function...
Kaz Baig
@kbaig
Apr 04 2018 15:42
(optional arg)
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:42
.reduce takes 2 parameters... first, the reducer function, second, the initial value (optional) that is passed to the reducer function (first parameter)
if you don't pass the ,0, .reduce will consider first element of array as inital value
Aniculaesei
@Aniculaesei
Apr 04 2018 15:43
@SweetCodingInc thank you!p.s two coffes :D
CamperBot
@camperbot
Apr 04 2018 15:43
api offline
aniculaesei sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:44
perhaps, it's easier to read and understand
function reducerFunction(accumulatedValue, currentValue){
  // some shit
}

arr.reduce( reducerFunction, 0 );
Aniculaesei
@Aniculaesei
Apr 04 2018 15:45
@SweetCodingInc Thank you again man!
CamperBot
@camperbot
Apr 04 2018 15:45
aniculaesei sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
api offline
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 15:47
@Aniculaesei :+1:
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:48
@kbaig oh finally a React Saviour. Here is my issue. Based on my components App.js has my React Router, Home.js has my home page component which I style with home.css. I made a Navigator component to handle navigation I Import Navigator to Signin Component but I am unable to style the Signin component properly.
Capture.JPG
Kaz Baig
@kbaig
Apr 04 2018 15:49
@RoniqueRicketts would you happen to have a repo
well the colors on the file tells me yes lol
I ask because the issue could be a couple of things. Would just be easier to see the code
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:55
Kaz Baig
@kbaig
Apr 04 2018 15:56
kk sec
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 15:58
@kbaig thanks in advance. hehehe. Excited :) btw don't laugh at my crabtoe coding. :)
CamperBot
@camperbot
Apr 04 2018 15:58
roniquericketts sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 588 | @kbaig |http://www.freecodecamp.org/kbaig
Kaz Baig
@kbaig
Apr 04 2018 15:59
@RoniqueRicketts no prob but I think the repo isn't up to date
there's no signin.css
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 16:01
How can I change the ℃ to ℉?
function convert(celsius) {
  // 请把你的代码写在这条注释以下
var fahrenheit;  



  // 请把你的代码写在这条注释以上
    return fahrenheit;
}

convert(30);  // 你可以修改这一行来测试你的代码
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:02
@kbaig let me push update sorry
totally forgot
Andrew Pope
@andrew1601
Apr 04 2018 16:03
@DerrickHsiao first you need to know the formula to change celsius to fahrenheit
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:03
Your good to go @kbaig
Kaz Baig
@kbaig
Apr 04 2018 16:03
F = (C - 32) * (5/9)
@DerrickHsiao
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:06
@DerrickHsiao use the celsius parameter multiplied by 9/5 then add 32; You can return this as @kbaig suggested.
Kudzu
@czhower
Apr 04 2018 16:08

F = (C - 32) * (5/9) < last () not needed, can be simply:

F = (C - 32) * 5 / 9

Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:10
@czhower
function convertToFahrenheit(celsius){
return (celsius - 32) * 5 / 9;
}
Kudzu
@czhower
Apr 04 2018 16:10
on visual scan, looks right
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:11
@czhower lol ya i didn't test this lol
Kudzu
@czhower
Apr 04 2018 16:11
The extra () didnt hurt, just arent needed.
Kaz Baig
@kbaig
Apr 04 2018 16:16
@RoniqueRicketts So the issue was that adding styles for Navigator within signin.css was having no effect?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:18
@kbaig kinda. If I add a Paragraph it is flushed behind the navbar so if I try to style using the signin.css file it moves the entire navbar. for both sign in and signup
Kaz Baig
@kbaig
Apr 04 2018 16:19
Sounds more like a styling issue than a React/CSS specificity issue
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:19
@kbaig oh so I was aking if the style is inheriting across components
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 16:23
I don't undersdent.............
function convert(celsius) {
  // 请把你的代码写在这条注释以下
  var fahrenheit= (celsius - 32)*(5/9);

  // 请把你的代码写在这条注释以上
    return fahrenheit;
}

convert(30);  // 你可以修改这一行来测试你的代码
Jason Luboff
@JLuboff
Apr 04 2018 16:24
@DerrickHsiao You're equation is incorrect. It is F = (C * 9/5) + 32
Kaz Baig
@kbaig
Apr 04 2018 16:24
@RoniqueRicketts yeah I don't think it matters which component you're importing the css to. I don't think that's a scoping mechanism
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:25

@DerrickHsiao try

 var fahrenheit = celsius *  (9 / 5) + 32;

instead

Jason Luboff
@JLuboff
Apr 04 2018 16:25
@RoniqueRicketts You're equation is also incorrect ;)
Kaz Baig
@kbaig
Apr 04 2018 16:26
@RoniqueRicketts I think people are typically using CSS Modules or CSS in JS solutions to get scoping
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:26
@kbaig oh damn!
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 16:28
@JLuboff @RoniqueRicketts @kbaig
Thanks! I pass now :smile:
CamperBot
@camperbot
Apr 04 2018 16:28
derrickhsiao sends brownie points to @jluboff and @roniquericketts and @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @roniquericketts |http://www.freecodecamp.org/roniquericketts
api offline
:cookie: 589 | @kbaig |http://www.freecodecamp.org/kbaig
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:28
@DerrickHsiao good vybe
@kbaig so you think a css module will fix this?
Derrick Hsiao
@DerrickHsiao
Apr 04 2018 16:30
@RoniqueRicketts what vybe mean? my english is not really well haha
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:30
@DerrickHsiao oh i meant good stuff
Kaz Baig
@kbaig
Apr 04 2018 16:30
@RoniqueRicketts you could just work around it by not relying on scoping via component imports
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:32
@kbaig ok meaning?
Kaz Baig
@kbaig
Apr 04 2018 16:33
@RoniqueRicketts treat each css file like any other css file
It doesn't matter whether you're working with react here or not
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:34
ok
Stephen James
@sjames1958gm
Apr 04 2018 16:58
@RoniqueRicketts Sorry - got a slack from a teammate about a C++ issue
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 16:59
@sjames1958gm ok bruv
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 17:46
@sjames1958gm needed help with react
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 17:54
Ahahaha @RoniqueRicketts whats wrong with react?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 17:54
@tiagocorreiaalmeida I have a design flaw I need help with
can u go on a join me?
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 17:55
In 15min or so will be on computer then I can try to help
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 17:55
Yeeee!!!! dancing hehehe
1Mher1
@1Mher1
Apr 04 2018 18:19
Hi please help me to change color and arial in this challenge https://codepen.io/1Mher1/pen/BrOQOZ
font-family and background don`t worked
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 18:33
so @RoniqueRicketts ?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 18:33
@tiagocorreiaalmeida one sec
@tiagocorreiaalmeida ready?
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 18:35
gettin g some food but well will be around so yeah im ready :D
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 18:35
cool
sent you a PM
1Mher1
@1Mher1
Apr 04 2018 18:36
please help me to find in javascript natural numbars using if
math.sqrt
Jason Luboff
@JLuboff
Apr 04 2018 18:43
What about Math.sqrt?
1Mher1
@1Mher1
Apr 04 2018 18:49
To print "true" at Button's clicks, if the whole number is a square and "false", otherwise
The square of natural numbers is 49 square, for example 7 * 7 = 49
For example, 46 is not the case because we will not get any number multiplied by 46
@JLuboff this challange I can't write
Markus Kiili
@Masd925
Apr 04 2018 18:51
@JLuboff Evening. What is up?
Jason Luboff
@JLuboff
Apr 04 2018 18:55
@Masd925 Just working. About to go to the gym during lunch..you?
@1Mher1 Do something like Math.sqrt(number) % 1 === 0
1Mher1
@1Mher1
Apr 04 2018 18:57
@JLuboff exact what code I replace and write this?
Markus Kiili
@Masd925
Apr 04 2018 18:58
@1Mher1 That condition tells you if a number is a perfect square.
Jason Luboff
@JLuboff
Apr 04 2018 18:59
@1Mher1 I don't know exactly what you're trying to do, but as @Masd925 said, my code will return true if its a square, false otherwise
Markus Kiili
@Masd925
Apr 04 2018 18:59
@JLuboff Trying to get in shape for nationals next Sunday.
Jason Luboff
@JLuboff
Apr 04 2018 19:00
@Masd925 What does getting in shape entail? Lots of cardio?
Markus Kiili
@Masd925
Apr 04 2018 19:02
@JLuboff Mostly yes, because I'm not in great shape because of the knee injury some time ago. Also I have to tone down eating as the week goes and fast in the weekend so bowel doesn't use all my oxygen during the dive.
Moisés Man
@moigithub
Apr 04 2018 19:02
in shape ..for sumo contest ? :)
Markus Kiili
@Masd925
Apr 04 2018 19:02
@moigithub Freediving.
1Mher1
@1Mher1
Apr 04 2018 19:03

var bnakan = true
document.getElementById("btn2").onclick=function(){
if(Math.sqrt(number) % 1 === 0){
bnakan=true
}else{
bnakan=false
}
var z=document.getElementById("inp3").value

}
console.log(bnakan)

they show me error
Jason Luboff
@JLuboff
Apr 04 2018 19:04
@1Mher1 number should be either a fixed number or a variable
@Masd925 Don't want to :poop: in the water
1Mher1
@1Mher1
Apr 04 2018 19:05
@JLuboff can you explain in code
Markus Kiili
@Masd925
Apr 04 2018 19:05
@JLuboff That would be something to pass out and also poop. Sometimes there is a live stream so would be embarrassing.
1Mher1
@1Mher1
Apr 04 2018 19:05
really I dont undertand
Jason Luboff
@JLuboff
Apr 04 2018 19:06
@1Mher1 I already did give it in code. In your example above, you don't define number anywhere. I was using number as a placeholder for either an actual number or a variable that contains a number
@Masd925 Just have a little turd floating around :joy:
Markus Kiili
@Masd925
Apr 04 2018 19:07
@JLuboff They would have to postpone the next diver for couple of hours so they could clean the pool.
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 19:23
@alpox around?
Ronique Ricketts
@RoniqueRicketts
Apr 04 2018 19:29
@tiagocorreiaalmeida thanks
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 19:41
@Masd925 around?
Markus Kiili
@Masd925
Apr 04 2018 19:44
@tiagocorreiaalmeida Yes.
Christopher McCormack
@cmccormack
Apr 04 2018 19:45
Yay they didn't shut this one down!
Brad
@bradtaniguchi
Apr 04 2018 19:45
only the general room
Christopher McCormack
@cmccormack
Apr 04 2018 19:45
Where did they all jump?
Tiago Correia
@tiagocorreiaalmeida
Apr 04 2018 19:46
nm got it working mocha is a bad guy tought I had issues on my code but atually the thing was timing out itself making the database request so I forced a long timeout still thanks
Brad
@bradtaniguchi
Apr 04 2018 19:46
idk, I know a bunch of people went on an unofficial discord, which happened a few days ago, which is why the general room was dead for a while
Christopher McCormack
@cmccormack
Apr 04 2018 20:01
I wouldn't mind moving to a discord or slack, are there any good professional rooms like this one to talk JS/Frameworks/etc..?
Unless they're going to keep a link to chat on FCC, that is
Brad
@bradtaniguchi
Apr 04 2018 20:03
Well I heard the discord room is filled with BS stuff, not oriented to professional stuff. Plus idk how anyone can figure out how to get there with an invite from an existing person. (there is a link floating around)
Kaz Baig
@kbaig
Apr 04 2018 20:03
Well I checked it out yesterday and indeed it was just people planning to spam the gitter
Brad
@bradtaniguchi
Apr 04 2018 20:04
But for FCC rooms, I think they really want us to migrate to the forums, otherwise this and the helpFrontEnd room I think are popular
Kaz Baig
@kbaig
Apr 04 2018 20:04
Noped out of there
Brad
@bradtaniguchi
Apr 04 2018 20:04
Yea sounds about right
Jody LeCompte
@jodylecompte
Apr 04 2018 20:04
You're taking the posts of a literal one person and spreading it across an entire group of people
Brad
@bradtaniguchi
Apr 04 2018 20:04
@jodylecompte Yea I guess we are
but I don't want to be in a room with that one person haha
Jody LeCompte
@jodylecompte
Apr 04 2018 20:05
In case anyone is curious, we do have a venting room on discord which as you would suspect, just for complaining. But there are also dedicated sections for chat about general topics as well as FCC and code , one section of which that are designed to be more professional than average
For example, "Clean and Educational" bans swearing
Kaz Baig
@kbaig
Apr 04 2018 20:05
Oh really
Brad
@bradtaniguchi
Apr 04 2018 20:05
How do you guys plan on getting new people to help?
Kaz Baig
@kbaig
Apr 04 2018 20:05
I guess I should give it another shot
Jody LeCompte
@jodylecompte
Apr 04 2018 20:05
I dont know about that part, Im not very familar with discord tbh
We tried it out with work a few months back because we were thinking about leaving slack, but thats about all of my experience with it
Brad
@bradtaniguchi
Apr 04 2018 20:06
I mean like how does an FCC camper find it, same thing happened to the general room is my understanding. (There was a link on the website to go to the general fcc room, but it was removed)
Jody LeCompte
@jodylecompte
Apr 04 2018 20:06
Not sure tbh, we've been trying to find ways to market and advertise while still being respectful to the FCC brand
Brad
@bradtaniguchi
Apr 04 2018 20:08
My view of it isn't good (and Im pretty forgiving) so it sounds like a tough task. I don't take it very seriously simply because of the bad apples. (I mean geez someone got banned by coming here and spamming I believe)
Jody LeCompte
@jodylecompte
Apr 04 2018 20:08
I can't speak for everyone; only myself; but my game plan is to continue to try to be a better person and help the people (both campers and otherwise) that come across my path
Brad
@bradtaniguchi
Apr 04 2018 20:09
Me too, I like being here as I think it helps me learn about other problem I wouldn't run into day-to-day, and I can possible help someone out
Jody LeCompte
@jodylecompte
Apr 04 2018 20:10
I'm glad they kept the holp rooms active
My concern was that some people just don't mesh well with forums personality wise, they p refer the dynamic of live chat
Christopher McCormack
@cmccormack
Apr 04 2018 20:14
Yeah live chat is so much less sterile, and far more forgiving if you provide a wrong answer or whatever. Just say whoops here's the correct answer and move on
Jason Luboff
@JLuboff
Apr 04 2018 20:19
@cmccormack
:wave:
Christopher McCormack
@cmccormack
Apr 04 2018 20:19
@JLuboff yo!
And without live chat how would I catch up with @JLuboff almost every day!?
Jason Luboff
@JLuboff
Apr 04 2018 20:19
Ya, Quincy messaged me on here to get my opinion of the forums as well as to give it a shot
@cmccormack I guess facebook seeing as how we're friends :joy:
Christopher McCormack
@cmccormack
Apr 04 2018 20:20
I got that too, last year in July
figured it would be the deathknell of the chat rooms
Jason Luboff
@JLuboff
Apr 04 2018 20:20
He just messaged me yesterday. Told him I much prefer the dynamic of the chat and he asked me to spend some time on the forum (aka give it a shot)
Kaz Baig
@kbaig
Apr 04 2018 20:21
Look at you :O
Jason Luboff
@JLuboff
Apr 04 2018 20:22
He said becuase I spend too much time on here... (well maybe not like that)
Christopher McCormack
@cmccormack
Apr 04 2018 20:22
Haha Fight the Power!
There must be something they get out of the forums that they don't out of the chat room - maybe SEO or something? I don't know
Kaz Baig
@kbaig
Apr 04 2018 20:24
Well yes, answers to questions are much more searchable in a forum format. That's one of the biggest pros of forum over chat - that answered questions don't have to be answered again
Brad
@bradtaniguchi
Apr 04 2018 20:24
^ yea, that might be why
Searching in gitter is pretty.... interesting
Kaz Baig
@kbaig
Apr 04 2018 20:25
Imagine getting brownie points for only answering a question that hasn't been answered before :O
Brad
@bradtaniguchi
Apr 04 2018 20:25
Then the only questions left unanswered would be hard as hell XD (like stack overflow haha)
Christopher McCormack
@cmccormack
Apr 04 2018 20:26
The great thing about chat is serendipity. I often see odd questions come up that I never thought about and therefore pursue the answers to and learn something. I would have to seek this out in the forums, and there wouldn't be a dialogue necessarily
There's not much in the way of community on the Forums either, last I checked. It's too slow - they're totally different mediums, why not have both?
Brad
@bradtaniguchi
Apr 04 2018 20:30
I like the idea of both, different things suit different people. I mean the best part of using forums is being able to refer back later incase your busy, or dont need feedback instantly. In chat things get lost really fast ya kno
Christopher McCormack
@cmccormack
Apr 04 2018 20:32
Yeah
it's like saying we have email, what's the point of calling people? We have text messages, why email? Everything suits a particular need/speed
Brad
@bradtaniguchi
Apr 04 2018 20:32
on a side note, the time npm install takes like 3 minutes cuse your HD is slow and you have WAY to many dependencies :(
@cmccormack Yea definantly, I was big with forums when I was younger, I didn't get the benefit of real time chat, now I feel like I changed backward haha
Eunice Park
@eunicode
Apr 04 2018 20:36
Would it be alright if one of you guys shared a link to discord or slack? I'm an occasional lurker, but there are many regulars that have helped me in the past and I would be sad if I never got to see them again, like Sky, Kumquat, etc.
Christopher McCormack
@cmccormack
Apr 04 2018 20:36
@bradtaniguchi me too! That may have been because, while IRC existed, it was also a haven for malware
Brad
@bradtaniguchi
Apr 04 2018 20:37
@eunipa Zac gave me this link: (I haven't tried it personally tho) https://discord.gg/EHueREz
@cmccormack I think around that time I was too scared of chat for whatever reason haha (I was in middle school and didn't understand the internet that much haha)
Christopher McCormack
@cmccormack
Apr 04 2018 20:39
@bradtaniguchi I still don't understand the Internet but now for very different reasons :D
Brad
@bradtaniguchi
Apr 04 2018 20:39
hahaha
Eunice Park
@eunicode
Apr 04 2018 20:43
@bradtaniguchi Thank you, I checked it out and I think gitter is still more active. Also don't recognize many peeps. I'm really sad fcc's gitter chats are getting phased out, I think they're an amazing resource. I've gotten so much help from kind strangers.
CamperBot
@camperbot
Apr 04 2018 20:43
eunipa sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 446 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
Apr 04 2018 20:43
@eunipa Np :D
Also, I should mention it is unofficial, and not part of FCC directly
Eunice Park
@eunicode
Apr 04 2018 20:45
Yep, I figured since there was a venting room haha
Jason Luboff
@JLuboff
Apr 04 2018 20:48
@cmccormack Your points about the forum are the same points (for the most part) I told Quincy
Christopher McCormack
@cmccormack
Apr 04 2018 20:49
@JLuboff Good man I hope he takes your wise words to heart
although to be honest I like the slower pace of better questions we see currently vs the flood of the same questions over and over we used to see...
Jason Luboff
@JLuboff
Apr 04 2018 20:51
True, but seeing different solutions to the same problem helped keep me sharp haha
Markus Kiili
@Masd925
Apr 04 2018 20:56
@JLuboff There should be only one!
Jason Luboff
@JLuboff
Apr 04 2018 20:57
@Masd925 What a poor attitude :P
Eunice Park
@eunicode
Apr 04 2018 20:57

I have a question about a solution to a FCC algorithm challenge. It's Sum All Primes https://www.freecodecamp.org/challenges/sum-all-primes
https://forum.freecodecamp.org/t/freecodecamp-algorithm-challenge-guide-sum-all-primes/16085/18

This is the solution:

function sumPrimes(num) {
  var numbers = [];

  //create an array of numbers up to and including num
  for (var i = 2; i <= num; i++) {
    numbers.push(i);
  }

  //filter all numbers in the 'numbers' array, that are not divisible by any number other than themselves without a remainder
  return numbers.filter(function(item, index, array) {
    for (var j = 0; j < index; j++) {
      if (item % array[j] === 0)
        return false;
    }
    return true;

  //sum up all numbers in the filtered array (=primes)
  }).reduce(function(a, b) {
    return a + b;
  });
}

I don't understand this part:

return numbers.filter(function(item, index, array) {
    for (var j = 0; j < index; j++) {
      if (item % array[j] === 0)
        return false;
    }
    return true;
  })

How can j be the less than the index? Because the initial value of j is 0, and isn't the index also 0?

Markus Kiili
@Masd925
Apr 04 2018 20:59
@eunipa index is the index of the numbers element being iterated.
Brad
@bradtaniguchi
Apr 04 2018 20:59
@eunipa Well, if your at index 0, and j is zero you don't gointo the loop. So you return true, so the first number is always returned automatically. (the number is always 2, which is prime)
Jason Luboff
@JLuboff
Apr 04 2018 20:59
I really don't like that they're using a for loop inside a filter thats then being reduced
Markus Kiili
@Masd925
Apr 04 2018 21:00
Not a good solution.
Jason Luboff
@JLuboff
Apr 04 2018 21:00
I don't mind the filter than reduce... but that loop inside is just...ugh
Markus Kiili
@Masd925
Apr 04 2018 21:01
Could easily turn that into something efficient.
Eunice Park
@eunicode
Apr 04 2018 21:01
@JLuboff Thanks for the best practices tip
CamperBot
@camperbot
Apr 04 2018 21:01
eunipa sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2392 | @jluboff |http://www.freecodecamp.org/jluboff
Markus Kiili
@Masd925
Apr 04 2018 21:02
@eunipa Nothing wrong about having a loop inside filter, but here there is just too much extra work done.
Eunice Park
@eunicode
Apr 04 2018 21:03
@Masd925 @bradtaniguchi thank you for replying. I guess I got confused bc I thought that j and index would always be the same bc j is the element being iterated, and index is the index of the element being iterated
CamperBot
@camperbot
Apr 04 2018 21:03
eunipa sends brownie points to @masd925 and @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:star2: 4758 | @masd925 |http://www.freecodecamp.org/masd925
api offline
Brad
@bradtaniguchi
Apr 04 2018 21:03
I think the first for loop can be removed, but the inner for loop in the filter makes sense, its checking if the number is prime, which requires a loop right?
Eunice Park
@eunicode
Apr 04 2018 21:04
@Masd925 I'll try thanking you again
Jason Luboff
@JLuboff
Apr 04 2018 21:06
@bradtaniguchi It might make sense but it's still so dirty... :P
Markus Kiili
@Masd925
Apr 04 2018 21:07
@JLuboff That would flunk in an algorithm class.
Jason Luboff
@JLuboff
Apr 04 2018 21:08
...I would probably fail an algorithm class :'(
Markus Kiili
@Masd925
Apr 04 2018 21:09
@JLuboff It is also nice to camouflage numbers as array.
Brad
@bradtaniguchi
Apr 04 2018 21:10
I mean I can see this working with just 2 nested loops, combining the filter and reduce's jobs. But I don't think it can go past that, but it wont be so "elegant", but hey it is what is is haha
Eunice Park
@eunicode
Apr 04 2018 21:13
@bradtaniguchi it only took me a million years, but I get it now. For the first element, the for loop block statement just gets skipped, and the filter function returns true, and then we move on to the next element in the array, and now j is less than the index. Thanks again for your explanation.
CamperBot
@camperbot
Apr 04 2018 21:13
eunipa sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
api offline
Brad
@bradtaniguchi
Apr 04 2018 21:14
@eunipa np :D
Eunice Park
@eunicode
Apr 04 2018 21:16
Sorry I couldn't give any brownie points. Anyways, this is why I love this chat so much. I learn so much. Tis really a shame it's not promoted anymore
I see lots of people creating an array of primes and summing it, so much extra work, just test for primes up to num and add em up!
Nate Mallison
@NJM8
Apr 04 2018 21:35
I could make mine more efficient by storing found primes and only testing for new ones up from there
Gulsvi
@gulsvi
Apr 04 2018 21:36
@NJM8 It's a clean solution. For better efficiency with larger numbers, you can loop up to the square root of the number in your isPrime function
for (let i = 2; i <= Math.sqrt(num); i++){
might be less efficient with small numbers though :)
Smootimus
@Smootimus
Apr 04 2018 22:46
Hello everyone :)
Joseph
@revisualize
Apr 04 2018 22:47
Hello.
Smootimus
@Smootimus
Apr 04 2018 22:47
How's it goin'
How's the activity been here?
Jason Luboff
@JLuboff
Apr 04 2018 22:55
Comes and goes
Smootimus
@Smootimus
Apr 04 2018 22:57
Like most things, eh
Jason Luboff
@JLuboff
Apr 04 2018 23:06
Yup! It was a little bit more lively today