These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Nov 2017
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:26
@JLuboff Hey Bro!
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:31
function smallestCommons(arr) {
  var i = 1, min, max, found = false;

  if (arr[0] < arr[1]) {
    min = arr[0];
    max = arr[1];
  }
  else {
    min = arr[1];
    max = arr[0];
  }

  while (!found) {
    for (var j = min; j <= max; j++) {
      console.log(j,i);
      if (i % j === 0) found = true;
      else found = false;
    }
    if (!found) i++;
  }
  return i;
}
I can't point out the error in this function. :l (Smallest common multiple challenge)
AbrisM
@AbrisM
Nov 02 2017 00:41
Hi all
Could someone tell me what is wrong with the JS on line 4? https://codepen.io/anon/pen/wPKXGG
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:42
@Morched23MJ what error are you getting?
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:44
Not an error, but an incorrect value. The algorithm seems correct to do the job. Check console and you'll see some values of j and i that shouldn't increase that way, @Lumexralph
@AbrisM, what are you trying to do there?
AbrisM
@AbrisM
Nov 02 2017 00:45
im trying to have stockarray in a range that, if the clicks go below zero an alert button pops up
For line 4 is the coding correct though? I get an unexpected token error
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:46
But, I see an undefined var storage
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:46
@AbrisM it's not correct, this is your code
var Stockarray=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
var count = 0;
function buymeFunction(index){
   Stockarray[index]--; 
   if (Stockarray[index]<=0){

   } storage <=0 window.alert("Inventory out of Stock"); // what's storage?    
   console.log (Stockarray);
}
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:46
var Stockarray=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
var count = 0;
function buymeFunction(index){
   Stockarray[index]--; 
  if (Stockarray[index]<=0) if (storage <=0) window.alert("Inventory out of Stock");
   console.log (Stockarray);
}
Did you mean to do the code like this? storage isn't defined though.
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:47
@AbrisM what do you mean by storage <=0 window. ?
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:47
@Lumexralph, did you try to understand my algorithm there? :l
AbrisM
@AbrisM
Nov 02 2017 00:47
that the variable storage is greater or equal to zero
storage is basicually the name of the variable I gave for the amount of items
storage is lesser or equal to zero*
Ah
Greater, sorry
korzo
@korzo
Nov 02 2017 00:49
@Morched23MJ You need 2 loops. 1 for the range and second for checking current value
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:49
@Morched23MJ i don't have values/arguments to check your function
AbrisM
@AbrisM
Nov 02 2017 00:50
while loops?
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:50
@korzo, I used the while loop to find the correct number i and the for loop, to go through the array given. :l
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:52
@Morched23MJ the for loop is not going through any array, is it?
Morchid Chellali
@Morched23MJ
Nov 02 2017 00:55
I gave the smallest value from the array to min, and the biggest to max, so it's going from min to max, both included.
korzo
@korzo
Nov 02 2017 00:56
@Morched23MJ Yeah, sorry, I missed the some brackets
also you are overwriting found value on every iteration so found will always have value of last iteration.
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:57
@Morched23MJ you're using the for loop, to generate values and check the value that divides through that's what I can observer but that doesn't add to the solution, what do you want the algorithm to do but it is not?
AbrisM
@AbrisM
Nov 02 2017 00:57
back
korzo
@korzo
Nov 02 2017 00:58
@Morched23MJ Also shouldn't it be if (i *max % j === 0) found = true; ?
Isaiah Trembley
@IsaiahCT
Nov 02 2017 00:58
yeah
Ogundele Olumide
@Lumexralph
Nov 02 2017 00:59
anyone used webpack hot reload module?
AbrisM
@AbrisM
Nov 02 2017 01:00
anyone know what's wrong with line 4?
Am I off a parathensis?
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:01
@korzo to make it quicker, you mean? since the least multiple of all numbers have to start from the max?
@AbrisM, I'm sorry I can't understand what you trying to do.
Ogundele Olumide
@Lumexralph
Nov 02 2017 01:01
@AbrisM @Morched23MJ showed you something :point_up: November 2, 2017 1:46 AM
AbrisM
@AbrisM
Nov 02 2017 01:01
Ahh I just seen it
@Morched23MJ Yes
Ogundele Olumide
@Lumexralph
Nov 02 2017 01:03
@AbrisM but mind you storage is still undefined
AbrisM
@AbrisM
Nov 02 2017 01:03
@Morched23MJ Basicually what I'm trying to do, I have the variable stockarray which represents 10 items that are at current capacity 10. The count which the items start at is at 0. With the buyme function I am using "index" to represent the stock. Using an If statement I am saying if the stock drops to zero then an alert will pop up and say "Inventory out of Stock"
Yes
hmm storage is suppose to represent those numbers, the 10's at the top
It's basicually suppose to be a vending machine
One weird problem I came across is that the numbers continued going down even after the 0 was reached
Dont know if anyone can see in console, but if you click one of the buttons you should see numbers adding up or going down
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:08
var Stockarray=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10];

function buymeFunction(index){

  if (Stockarray[index] == 0) window.alert("Inventory out of Stock");
   console.log (Stockarray);
else Stockarray[index]--; 
}
Then this should do the job. If there are items it decreases since one item is bought, else if there are none (0), it alerts.
AbrisM
@AbrisM
Nov 02 2017 01:09
Wow just ran out of battery juice!
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:09
Numbers went down even though there are no items, because you did Stockarray[index]--; everytime the function is called. Where it should be with an if statement if stock is avaible, else it alerts.
AbrisM
@AbrisM
Nov 02 2017 01:11
hmm keeps saying unexpected token even though I changed the code, Morchid
Strange
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:11
Give me the pen's link?
Isaiah Trembley
@IsaiahCT
Nov 02 2017 01:15
how would I xpress an image in coding?
AbrisM
@AbrisM
Nov 02 2017 01:26
Sure
Unexpected Token else
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:30
var Stockarray=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10];

function buymeFunction(index){

  if (Stockarray[index] == 0) window.alert("Inventory out of Stock");
else Stockarray[index]--; 
   console.log (Stockarray);
}
This is the correct code. @AbrisM
AbrisM
@AbrisM
Nov 02 2017 01:35
Okay, it is working now
I see one error but it is for favio.icon
I am checking console, yes I see the numbers go down and the alert
Hmm i'm not sure why it's not working for the second row of items
perhaps I need to make another var
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:38
It is working..
AbrisM
@AbrisM
Nov 02 2017 01:40
Yes
Couldn't see it running the website itself
It is working
AbrisM
@AbrisM
Nov 02 2017 01:49
On line 36 in the .html section the code <div id="count1"><div id="count"></div> needs to be displayed so that it is above each item
However it stretches itself over all 5 top items in the first row. How do I reduce it so that it's above each item?
Plus we can't see the click counts anymore too
korzo
@korzo
Nov 02 2017 01:51
@Morched23MJ
did you solve it already?
Morchid Chellali
@Morched23MJ
Nov 02 2017 01:57
Nope :l
@korzo
korzo
@korzo
Nov 02 2017 01:58
@Morched23MJ You have problem, that you always rewrite found variable. So it will always has value for last iteration of for.
@Morched23MJ You can fix it simple by adding found = true before for loop
Then change condition to
      if (i % j !== 0) {
        found = false;
        break;
      }
AbrisM
@AbrisM
Nov 02 2017 02:00
Thanks!
Alright, another question. How would I write the code in order to restock all items?
Morchid Chellali
@Morched23MJ
Nov 02 2017 02:02
It worked, @korzo. Thanks!
CamperBot
@camperbot
Nov 02 2017 02:02
morched23mj sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 719 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
Nov 02 2017 02:04
@Morched23MJ I had to decipher my too smart solution at first :)
Glad to help
Morchid Chellali
@Morched23MJ
Nov 02 2017 02:06
@korzo it doesn't work for [18, 23] but does for [18, 22]. Bizzard. :l
korzo
@korzo
Nov 02 2017 02:07
@Morched23MJ try to add // noprotect
as first line
Morchid Chellali
@Morched23MJ
Nov 02 2017 02:07
As I understand, the browser thinks it's a infinite loop, since it takes time? :DD
korzo
@korzo
Nov 02 2017 02:07
yes
and it's while loop
Morchid Chellali
@Morched23MJ
Nov 02 2017 02:09
Alright, now only Simon Game project and 3 advanced challenges left. Haven't been active due to studies...
Thank you, korzo.
Lean Junio
@leanjunio
Nov 02 2017 04:18

Hey guys, can anybody tell me where I’m going wrong?

class Weather {

  init() {
    console.log('this # 1: ', this)
    console.log(this);

    // cannot access this.location, returns undefined
  }

  getCurrentLocation() {
    $.getJSON('http://ip-api.com/json', (data) => {
      this.location = data;
    });
  }
}

var w = new Weather();
w.init();

Big thanks

aside from the fact that I forgot to declare the function...

sorry,

class Weather {

  init() {
    this.getCurrentLocation();
    console.log(this);
    console.log(this.location);

    // cannot access this.location, returns undefined
  }

  getCurrentLocation() {
    $.getJSON('http://ip-api.com/json', (data) => {
      this.location = data;
    });
  }
}

var w = new Weather();
w.init();

is the correct one…I cannot access this.location

Brian
@BrianCodes33
Nov 02 2017 04:49
are you sure the url is correct?
Henry
@GitHub-Henry
Nov 02 2017 05:05
@leanjunio in your thinking, what is this
Lean Junio
@leanjunio
Nov 02 2017 05:06
the Weather scope
Henry
@GitHub-Henry
Nov 02 2017 05:14
@leanjunio perhaps something like if (navigator.geolocation) { var lon = 'lon='; var lat = 'lat='; navigator.geolocation.getCurrentPosition(function(position){ lon += position.coords.longitude; lat += position.coords.latitude; //getWeather(lon, lat); });
Long Nguyen
@longnt80
Nov 02 2017 06:36
@GitHub-Henry how do I add methods to an already defined class?
Henry
@GitHub-Henry
Nov 02 2017 06:41
@longnt80 es6 classes are a layer above prototypes, that's my understanding, so I'd be inclined to try the following Adding a Method To an Object, is this along the lines of what you were thinking?
Long Nguyen
@longnt80
Nov 02 2017 06:42
@GitHub-Henry so I just use Class.prototype.method =?
Henry
@GitHub-Henry
Nov 02 2017 06:43
@longnt80 from the example myFather.name = function () { return this.firstName + " " + this.lastName; };
Long Nguyen
@longnt80
Nov 02 2017 06:44
@GitHub-Henry oh thanks
CamperBot
@camperbot
Nov 02 2017 06:44
longnt80 sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 449 | @github-henry |http://www.freecodecamp.com/github-henry
Henry
@GitHub-Henry
Nov 02 2017 06:44
@longnt80 no problem, :shipit: :sparkles:
Long Nguyen
@longnt80
Nov 02 2017 06:45
@GitHub-Henry but is this the same as adding method to a defined class?
I'm confused by the terms
myFather is an object, and myFather.nameis adding property to an object, right?
I got this question from a job interview and not really sure what's the answer
Henry
@GitHub-Henry
Nov 02 2017 06:47
@longnt80 depends on which example you look at here's another example.
function Person(first, last, age, eyecolor) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eyecolor; } Person.prototype.name = function() { return this.firstName + " " + this.lastName; };
Long Nguyen
@longnt80
Nov 02 2017 06:48
yeah, I think this is more along the line what the question asked for
Henry
@GitHub-Henry
Nov 02 2017 06:49
the page i referenced above would be a good thing to review, actually, i had plans to review to also
js objects still need to be solid in my mind as well
Long Nguyen
@longnt80
Nov 02 2017 06:51
yeah that w3 page explains it pretty well
Henry
@GitHub-Henry
Nov 02 2017 06:52
@longnt80 when you are ready, consider viewing this it won't make sense until you have enough knowledge, you might be ready.
Ashwin
@ashwins93
Nov 02 2017 06:52
@longnt80 have you read YDKJS?
Long Nguyen
@longnt80
Nov 02 2017 06:53
@ashwins93 yes, not finished yet
Henry
@GitHub-Henry
Nov 02 2017 06:53
@longnt80 YDKJS
Ashwin
@ashwins93
Nov 02 2017 06:54
@longnt80 it will be very helpful for interviews
Long Nguyen
@longnt80
Nov 02 2017 06:56
good idea, I'll try to find the related content from YDKJS @ashwins93
thanks
CamperBot
@camperbot
Nov 02 2017 06:56
longnt80 sends brownie points to @ashwins93 :sparkles: :thumbsup: :sparkles:
:cookie: 411 | @ashwins93 |http://www.freecodecamp.com/ashwins93
Henry
@GitHub-Henry
Nov 02 2017 07:34
@longnt80 tip, if you are going to follow along and code the examples you see from YDKJS, you might consider adding ScratchJS to Chrome to get something like this to easily code JS & ES6 and see console results
Long Nguyen
@longnt80
Nov 02 2017 07:35
@GitHub-Henry thanks man, just what I need
CamperBot
@camperbot
Nov 02 2017 07:35
longnt80 sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
api offline
Henry
@GitHub-Henry
Nov 02 2017 07:36
@longnt80 thought it would help you, :shipit: :sparkles:
Henry
@GitHub-Henry
Nov 02 2017 07:42
@longnt80 also, if you don't sign into Chrome consider doing it if you use multiple machines, virtual and real, cuz, your settings, extension, themes, etc, can be synchronized between machines, really helps if you like maintaining an environment, also, you can have multiple logins, so one login will bring in one set of settings and another login will bring in another set of settings, extensions, themes, etc.
Long Nguyen
@longnt80
Nov 02 2017 07:43
@GitHub-Henry yep already do this :+1:
tomorrow, I'll have 2 tests with 2 companies
Henry
@GitHub-Henry
Nov 02 2017 07:45
sounds like you're firing on all cylinders, :boom:
Henry
@GitHub-Henry
Nov 02 2017 08:07
@longnt80 good luck, :shipit: :dizzy:
段段
@ddkun
Nov 02 2017 09:52
按照下面的顺序,并且用空格来分割:
反斜杠 制表符 退格符 回车符 换行符 并把它赋值给变量 myStr
canyou answer the question
???
canyou help me?
wza62692371
@wza62692371
Nov 02 2017 13:39

function convert(celsius) {
// 请把你的代码写在这条注释以下
var Celsius=30;
var fahrenheit=Celsius*9/5+32;

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

convert(0); // 你可以修改这一行来测试你的代码

哪个大神知道这里错哪里了
半天看不出来
mstellaluna
@mstellaluna
Nov 02 2017 13:40
@wza62692371 you don't need to put Celcius as a variable as its a parameter that's passed to the function. the value of what's entered to the function will already be associated to Celcius...
Diego Mayer
@Chrono79
Nov 02 2017 13:41
@wza62692371 don't create a Celsius var, use celsius param (note the capitalization difference)
wza62692371
@wza62692371
Nov 02 2017 13:46
HHHHH
OKOK
i understande
mstellaluna
@mstellaluna
Nov 02 2017 13:47
:)
wza62692371
@wza62692371
Nov 02 2017 13:47
im CN are U?
mstellaluna
@mstellaluna
Nov 02 2017 13:48
no
Diego Mayer
@Chrono79
Nov 02 2017 14:00
@wza62692371 There is a FCC chinese room: https://gitter.im/FreeCodeCamp/chinese
eswhy27
@eswhy27
Nov 02 2017 14:50

hello working on the "profile lookup" challenge. When I run only the first part of my code only the without the else stmts the code works..but when I add the else stmts it doesn't perform the lookup and only the else stmts run correctly

for(i=0; i<contacts.length;i++){

if(firstName===contacts[i].firstName && contacts[i].hasOwnProperty(prop)){

  return contacts[i][prop];}

else if(firstName!==contacts[i].firstName){
return "No such contact";

}
else {
return "No such property";

}}

Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:18
@tiagocorreiaalmeida I am stuck on it already so I am off to beta.freecodecamp.com to do the backend content
Jason Luboff
@JLuboff
Nov 02 2017 15:20
@RoniqueRicketts Stuck on what?
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:22
@JLuboff the stupid learnyounode challenge. I leartn more from the nodejs official documentation guide than the learnyounode on fcc
I don't think its effective
Jason Luboff
@JLuboff
Nov 02 2017 15:22
Hence why I said its garbage/trash/sucks/terrible/etc
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:23
@JLuboff hahaha. yuh know di think mi chargie
Lean Junio
@leanjunio
Nov 02 2017 15:27
Can anybody tell me what constructor.prototype is pointing towards?
function Person(saying) {
  this.saying = saying
}

Person.prototype.talk = function() {
  console.log('I say: ', this.saying)
}

function new(constructor) {
  var obj = {}
  Object.setPrototypeOf(obj, constructor.prototype)
  constructor.apply(obj, [])
}

var crockford = new(Person, 'SEMICOLONS!!!')
crockford.talk()
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:28
@JLuboff What framework do you use with your nodejs?
Jason Luboff
@JLuboff
Nov 02 2017 15:29
@RoniqueRicketts backend or frontend framework? IF backend, express its the only way to go
Well not only..but..you get it
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:34
@JLuboff Yeah I know a little express but I need practice with backend
So what do you use for nodejs frontend? PUG?
Jason Luboff
@JLuboff
Nov 02 2017 15:34
hbs
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:34
what is that?
Jason Luboff
@JLuboff
Nov 02 2017 15:34
handlebars
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:36
oh I am not sure how to wire up the express backend to connect to reactjs front end
Jason Luboff
@JLuboff
Nov 02 2017 15:37
That I'm not sure
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:38
I have some idea based on the create-react-app bootstrap but I haven't put it in practice.
Ashwin
@ashwins93
Nov 02 2017 15:39
@RoniqueRicketts use webpack
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:40
I am pretty much stuck on the project I've sent you recently. I found out how to use node with sql but then I am still researching how to wire up everything so my projects would take REACT, D3, Auth0 Expressjs, Nodejs, and SQL
@ashwins93 I have this link in my arsenal. Idk why I didn't read this. I found it in my bookmarks when I tried to bookmark it. hmm. this is good
Ashwin
@ashwins93
Nov 02 2017 15:42
lol this is the only link that turns up on google
the only one written in a simple way to understand
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 15:45
i'll have to go through it later on today. As soon as I am done with the nodejs api guide.
eswhy27
@eswhy27
Nov 02 2017 15:56
can someone please help me with the profile lookup, not sure where I am returning incorrectly
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
  if(firstName===contacts[i].firstName){
    if(contacts[i].hasOwnProperty){
      return contacts[i][prop];}

    return "No such property";
  }}
  return "No such contact";
Ashwin
@ashwins93
Nov 02 2017 16:08
@eswhy27 contacts[i].hasOwnProperty you have to pass some argument to this function
hasOwnProperty(some_prop_name)
eswhy27
@eswhy27
Nov 02 2017 16:17
@ashwins93 right i threw (prop) in there
still struggling to get the "No such property" and "no such contact to work correclty
Diego Mayer
@Chrono79
Nov 02 2017 16:45
@eswhy27 try to use indentation properly
This message was deleted
Jason Luboff
@JLuboff
Nov 02 2017 16:45
@Chrono79 @cmccormack :wave:
Christopher McCormack
@cmccormack
Nov 02 2017 16:46
@JLuboff yo
@Chrono79 hi
Diego Mayer
@Chrono79
Nov 02 2017 16:46
:wave:
Christopher McCormack
@cmccormack
Nov 02 2017 16:46
@JLuboff question if you got a sec
Jason Luboff
@JLuboff
Nov 02 2017 16:46
Sure
Diego Mayer
@Chrono79
Nov 02 2017 16:46
The }} is misleading ;)
Christopher McCormack
@cmccormack
Nov 02 2017 16:47
@Chrono79 yeah :)
@JLuboff I'm playing with node authentication (no libraries just raw) - if I wanted to add a session ID I got back from a successful auth in local storage, how would you do that? I was thinking of throwing the ID in an html tag or something to be read later by JS but not sure
Jason Luboff
@JLuboff
Nov 02 2017 16:51
@cmccormack I haven't dealt with "raw" authentication :D but why not use cookies/sessions? express-session allows you to write to a session-persistent cookie (I think its a cookie since you don't need cookie-parser but I'm not 100% on that) that you can access from the backend
Christopher McCormack
@cmccormack
Nov 02 2017 16:52
I don't need to access from the backend, the user needs to use that session id as part of their REST request header

I was going to use cookie but Mozilla was recommending using alternate methods:

Cookies were once used for general client-side storage. While this was legitimate when they were the only way to store data on the client, it is recommended nowadays to prefer modern storage APIs. Cookies are sent with every request, so they can worsen performance (especially for mobile data connections). Modern APIs for client storage are the Web storage API (localStorage and sessionStorage) and IndexedDB.

although cookies would probably make this easier as I can send the session ID seperate from the response...
Jason Luboff
@JLuboff
Nov 02 2017 16:54
Hmmm... then I'm not sure. I had tried using localStorage before when I was working on my Voting app I think and couldn't get it to work for me
Christopher McCormack
@cmccormack
Nov 02 2017 16:57
@JLuboff thanks - I think I was too focused on getting localstorage to work I didn't think about how I could use the set-cookie response I'm already getting from the REST API
CamperBot
@camperbot
Nov 02 2017 16:57
cmccormack sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2244 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Nov 02 2017 16:57
:+1:
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:06
hello everyone
Jason Luboff
@JLuboff
Nov 02 2017 17:06
Hello
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:07
hello
Jason Luboff
@JLuboff
Nov 02 2017 17:07
Whats good?
Christopher McCormack
@cmccormack
Nov 02 2017 17:09
@tiagocorreiaalmeida hiya
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:10
all cool, and you? hey @cmccormack got the 3 week homework done ? eheh
Christopher McCormack
@cmccormack
Nov 02 2017 17:10
not yet still watching the videos when I have time
Almost to the homework though :)
Jason Luboff
@JLuboff
Nov 02 2017 17:12
@tiagocorreiaalmeida At work but on :baby: watch...any day now..
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:13
@JLuboff congrats man. Seems like your baby investment paid off :trollface:
Jason Luboff
@JLuboff
Nov 02 2017 17:13
The investment is only beginning :joy:
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:14
this week videos we're atually worth it, didnt knew there was a skip should read more documentation :D you had a son?
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:14
@JLuboff how so. I meant u invested in your wife and got a baby.
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:15
been learning scss tbh after this you dont wanna write more vanilla css
and its quite easy to learn if you allready know css
Jason Luboff
@JLuboff
Nov 02 2017 17:16
@RoniqueRicketts Meaning babies are expensive, but it'll all be worth it
Christopher McCormack
@cmccormack
Nov 02 2017 17:16
@tiagocorreiaalmeida yeah SCSS just seems more intuitive than CSS.
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:16
and learned about bem
it makes it so easy to get all things organized
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:17
@JLuboff I was congratulating you on the baby making process. People always congrateulate the mom and not the dad for putting in all that hard work. :trollface:
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:18
there's a few jokes about what you just mentioned but I wont say them... :D @RoniqueRicketts
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:19
@tiagocorreiaalmeida really... :) I guess I am not the only one who thinks on these things :D
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:20
forgot to tell you but there's a tutorial off someone that sets up node with mongo + express and even auth with passport if you are interested will try to find the one I saw
of
and sql*
Jason Luboff
@JLuboff
Nov 02 2017 17:21
@RoniqueRicketts Ah. Well thanks haha
CamperBot
@camperbot
Nov 02 2017 17:21
jluboff sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
Roy
@bommerhondjes14
Nov 02 2017 17:21
Can I ask a question regarding node js? I'm trying to create a discord bot
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:21
@JLuboff yw man.
Jason Luboff
@JLuboff
Nov 02 2017 17:22
@bommerhondjes14 You can ask...we may or may not have answers :D
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:23
I was introduced to Microsfot cognitive services. Have you guys ever used any of these before?
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:24
@RoniqueRicketts https://www.youtube.com/watch?v=gYjHDMPrkWU not sure if you still need it tough
well that got bigger than expected
Roy
@bommerhondjes14
Nov 02 2017 17:25
Ok so I'm trying to check for a message in Discord, and if a person with a certain role(in this case admin) sends the bot needs to send a message to him. But I keep getting this error: SyntaxError: Unexpected end of input
const Discord = require("discord.js");
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    if(!message.member.roles.some(r=>["admin"].includes(r.name)) ) 
        return message.reply("pong");
}

client.login('Mzc1NjIwMjU0NDE3NTUxMzYw.DNzNpg.dLCIKQSCVuDvx_rU2xxh_S3lNI8');
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:26
missing one }
after the clint on
client.on('message', msg => {
if (msg.content === 'ping') {
if(!message.member.roles.some(r=>["admin"].includes(r.name)) )
return message.reply("pong");
}
missing the closing one
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:26
@tiagocorreiaalmeida thanks. I am constantly willing to learn man. I am game
CamperBot
@camperbot
Nov 02 2017 17:26
roniquericketts sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Roy
@bommerhondjes14
Nov 02 2017 17:28
Oh, lol thanks @tiagocorreiaalmeida

Ok so now I'm getting this error: SyntaxError: missing ) after argument list
With this code:

const Discord = require("discord.js");
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
    if (msg.content === 'ping') {
        if(!message.member.roles.some(r=>["admin"].includes(r.name)) ){
            return message.reply("pong");
        }
    }
}  

client.login('Mzc1NjIwMjU0NDE3NTUxMzYw.DNzNpg.dLCIKQSCVuDvx_rU2xxh_S3lNI8');

I"m not missing a )?

Lean Junio
@leanjunio
Nov 02 2017 17:31
you are misssing ) at the end of on method
Roy
@bommerhondjes14
Nov 02 2017 17:32
if I add an ) after => it doesn't work
Christopher McCormack
@cmccormack
Nov 02 2017 17:32
@bommerhondjes14
client.on('message', msg => {
    if (msg.content === 'ping') {
        if(!message.member.roles.some(r=>["admin"].includes(r.name)) ){
            return message.reply("pong");
        }
    }
} ) // <===
Jason Luboff
@JLuboff
Nov 02 2017 17:32
@bommerhondjes14 After your last } on the second on method
Lean Junio
@leanjunio
Nov 02 2017 17:32
is ‘msg’ your parameter? it should be(msg) => {}
Jason Luboff
@JLuboff
Nov 02 2017 17:33
@leanjunio You don't need parenthesis there
If its a single paramter, no parenthesis needed
Christopher McCormack
@cmccormack
Nov 02 2017 17:33
@leanjunio single parameter doesn't need wrapped parens
Lean Junio
@leanjunio
Nov 02 2017 17:33
ah, right
Jason Luboff
@JLuboff
Nov 02 2017 17:33
multiple params, parens is required
Lean Junio
@leanjunio
Nov 02 2017 17:33
then in that case, it’s just the end there
Christopher McCormack
@cmccormack
Nov 02 2017 17:33
@bommerhondjes14 get used to ensuring your final } is followed by a ) when using arrow notation. Everything after 'message', is a callback function but you still need to close your .on invocation
Roy
@bommerhondjes14
Nov 02 2017 17:34
Well I copied this code from somewhere and since I'm pretty new to programming I had no clue where to look
But thanks alot peeps, I'll keep this in mind for the next time!
Lean Junio
@leanjunio
Nov 02 2017 17:35
in that case, it might be better for you to use ES5 first than ES6
I was in that exact same spot a few months ago
Roy
@bommerhondjes14
Nov 02 2017 17:35
And what's the difference?
Lean Junio
@leanjunio
Nov 02 2017 17:35
quite a bit
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:38
I think you should learn the basics first before trying to do what you trying to do
Lean Junio
@leanjunio
Nov 02 2017 17:38
I recommend you check out fun fun function from youtube and look at his videos about callback functions
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 17:38
I guess everyone know fun fun function :D
Lean Junio
@leanjunio
Nov 02 2017 17:39
lol, he’s one of the only youtubers that I see that really dive in to the theory aspect
Christopher McCormack
@cmccormack
Nov 02 2017 17:40
callback functions are one of those weird things that are super useful but not immediately intuitive
Lean Junio
@leanjunio
Nov 02 2017 17:40
@cmccormack they confused the hell out of me when I started getting into ajax requests lol
Christopher McCormack
@cmccormack
Nov 02 2017 17:41
@leanjunio yeah - it wasn't until I started digging into documentation more where they made perfect sense. The docs describe the callback handler, but it all seems so ethereal when you're just writing the code
Lean Junio
@leanjunio
Nov 02 2017 17:42
lol, i had the worst time going through javascript docs.
Christopher McCormack
@cmccormack
Nov 02 2017 17:43
It is pretty boring :) I read through the entire api when I can for new stuff I"m working with, just so I have an idea of what methods are available
Lean Junio
@leanjunio
Nov 02 2017 17:43
lol
Christopher McCormack
@cmccormack
Nov 02 2017 17:43
not every api of course :) but stuff like express - it's very good to know how it all works
Roy
@bommerhondjes14
Nov 02 2017 17:43
Well I'd like to get into javascript, especially so I can create a Discord Bot. But I have no clue where to start and what things to make
Christopher McCormack
@cmccormack
Nov 02 2017 17:44
@bommerhondjes14 this is FCC - go through the FCC projects, you learn on the way
It also helps a ton to break down what you're trying to do into small pieces, and then figure out how to make that piece work
Lean Junio
@leanjunio
Nov 02 2017 17:44
@bommerhondjes14 have you done any programming before?
Christopher McCormack
@cmccormack
Nov 02 2017 17:44
you should almost never copy code, but instead take an example and try to do something slightly different on your own
Roy
@bommerhondjes14
Nov 02 2017 17:47
I'm currently learning PHP HTML and CSS on school
@leanjunio
Ronique Ricketts
@RoniqueRicketts
Nov 02 2017 17:48
My brother wants to rejoin fcc I hope he stays this time. Like my earlier self he thought he couldn't get help with his code.
Lean Junio
@leanjunio
Nov 02 2017 17:48
@bommerhondjes14 They haven’t taught you js yet?
Roy
@bommerhondjes14
Nov 02 2017 17:50
Just a very small bit, things like alert and document.getElementById
But nothing further than that
Lean Junio
@leanjunio
Nov 02 2017 17:50
oh okay, how did you end up with that es6 code you pasted?
Roy
@bommerhondjes14
Nov 02 2017 17:51
well I decided to stop and pick up a javascript course on FCC, since I just copied some and had no clue what it meant
Lean Junio
@leanjunio
Nov 02 2017 17:53
ah i see
well a good way to see if something is in es6 is if you never see the word function in what looks to be a function, also if you see the arrow ( => )
To get a feel for JavaScript syntax and if you’re a tutorial/video kinda guy, I’d recommend trying out NetNinja in youtube
He has a nice series on JavaScript
Roy
@bommerhondjes14
Nov 02 2017 17:56
Alright, thanks alot!
Lean Junio
@leanjunio
Nov 02 2017 17:57
no worries
Alex
@alexandrupintilei
Nov 02 2017 20:48
Can someone tell me why i get this error? the (jQuery); solution,dosent work
image.png
Kaz Baig
@kbaig
Nov 02 2017 20:51
@alexandrupintilei hmm what are you trying to select
could you link a pen if possible
Alex
@alexandrupintilei
Nov 02 2017 20:51
sec
oke
Jason Luboff
@JLuboff
Nov 02 2017 21:02
@alexandrupintilei You don't have jquery as a dependency in the JS settings.
Kaz Baig
@kbaig
Nov 02 2017 21:03
that's not it
he just made the pen for the question
@alexandrupintilei but one problem with the pen is that #contentPost is not in it
@alexandrupintilei also, the load function is deprecated as of version 1.8 https://api.jquery.com/load-event/
Alex
@alexandrupintilei
Nov 02 2017 21:07
@kbaig replace #contentPost with #txtdisplay
@kbaig
image.png
load is deprecated mate
Alex
@alexandrupintilei
Nov 02 2017 21:11
@kbaig oh,ok.Why you post that pen?
i see,the alternative,but something is wrong.text dosent appear :(
Uriel Guzmán
@Burinson
Nov 02 2017 21:24
function truthCheck(collection, pre) {
  // Is everyone being true?

  var result = '';

    for (let x in collection) {
       if (collection[x].hasOwnProperty(pre)) {
         result = true;
       } else {
         result = false;
       }
      console.log(result);

    }
return result;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
I need help
Why doesn't this work?
alpox
@alpox
Nov 02 2017 21:47
@Burinson you only look at the last object of the array because you reset resulteach iteration. Therefore, result will end up being what it was set to in the last iteration.
Uriel Guzmán
@Burinson
Nov 02 2017 21:49
@alpox
function truthCheck(collection, pre) {
  // Is everyone being true?
  var result = '';
for ( var i in collection){
 if(!collection[i][pre])
return false;
} 
return true;
}
Fixed it with this method,
@alpox thanks
CamperBot
@camperbot
Nov 02 2017 21:49
burinson sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1426 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Nov 02 2017 21:50
@Burinson np :)
Tiago Correia
@tiagocorreiaalmeida
Nov 02 2017 22:21
@kbaig I know that picture from somewhere are you taking an udemy course?
dyon3334
@dyon3334
Nov 02 2017 23:49
can someone tell me why i not get NEGATIVE_INFINITY
console.log(Number.MIN_VALUE-10)
VM546:1 -10
korzo
@korzo
Nov 02 2017 23:51
@dyon3334 because Number.MIN_VALUE is value closest to 0
Not most negative number
dyon3334
@dyon3334
Nov 02 2017 23:52
@korzo thanks can you tell me how i can the most negative number ?
CamperBot
@camperbot
Nov 02 2017 23:52
:cookie: 723 | @korzo |http://www.freecodecamp.com/korzo
dyon3334 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
korzo
@korzo
Nov 02 2017 23:52
@dyon3334 Number.NEGATIVE_INFINITY
dyon3334
@dyon3334
Nov 02 2017 23:53
yes i know but i want to make somethin like
function inf (a,b){
var answer = a * b;
if (answer === Number.POSITIVE_INFINITY){
console.log("to high")}
else{console.log(answer)}
}
korzo
@korzo
Nov 02 2017 23:54
then maybe Number.MIN_SAFE_INTEGER
or Number.MAX_SAFE_INTEGER
dyon3334
@dyon3334
Nov 02 2017 23:55
can you tell e the difference between MIN_VALUE and MIN_SAFE_INTEGER
korzo
@korzo
Nov 02 2017 23:57
MIN_VALUE is closest to zero
MIN_SAFE_INTEGER is the minimum (negative) safe integer
@dyon3334 In other words, MIN_VALUE is zero, MIN_SAFE_INTEGER is -9007199254740991