These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Aug 2017
Joseph
@Big-jo
Aug 08 2017 00:04
image.png
i keep getting this error and no response from google maps api
does anyone have any idea whats happening
korzo
@korzo
Aug 08 2017 00:09
@Big-jo what's the text of the error?
korzo
@korzo
Aug 08 2017 00:11
@Big-jo Take a look in network panel in dev tools. There should be status code and response from server. But I think your url is in wrong format
Stephen James
@sjames1958gm
Aug 08 2017 00:11
@Big-jo Click on the network tab and you can see what the http response code is. When I click on that URL
{
"error_message": "Invalid request. Missing the 'address', 'bounds', 'components', 'latlng' or 'place_id' parameter.",
"results": [],
"status": "INVALID_REQUEST"
}
Joseph
@Big-jo
Aug 08 2017 00:13
@sjames1958gm i just realized, i think i have a solution but also another problem
i have this src (<script src="https://maps.googleapis.com/maps/api/geocode/json?State&key=AIzaSyBCyqeNvQ2ykQl524BcIWr_XAJwApEyWZU "></script>) the State is actually supposed to be supplied by an object property , so how do i get it in there?
<script src="https://maps.googleapis.com/maps/api/geocode/json?State&key=AIzaSyBCyqeNvQ2ykQl524BcIWr_XAJwApEyWZU "></script>
The State after json and ? is to be given by me but i want to get it from the people using my website and supply it to the src attribute
korzo
@korzo
Aug 08 2017 00:17
@Big-jo take a look at documentation. Valid parameters are either address or components
If or lat/log in reverse
Joseph
@Big-jo
Aug 08 2017 00:19
@korzo yh i looked at it but is there anyway i can make the address part of it dynamic, so it can change depending on the user
Joel Y.
@zapcannon99
Aug 08 2017 00:19
Can't you use jquery and innerHTML?
Joseph
@Big-jo
Aug 08 2017 00:20
how? in this situation
korzo
@korzo
Aug 08 2017 00:21
@Big-jo what you are trying to get from api?
coordinates?
Joel Y.
@zapcannon99
Aug 08 2017 00:21
idk, what needs to be dynamic. The location?
Joseph
@Big-jo
Aug 08 2017 00:22
@korzo yes
@zapcannon99 yes
korzo
@korzo
Aug 08 2017 00:23
@korzo then use url like https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
Joel Y.
@zapcannon99
Aug 08 2017 00:23
hmmm
Joseph
@Big-jo
Aug 08 2017 00:25
i finally got it to work but then got an uncaught syntax error
korzo
@korzo
Aug 08 2017 00:25
@Big-jo but you have to url encode it
Joseph
@Big-jo
Aug 08 2017 00:25
image.png
Joel Y.
@zapcannon99
Aug 08 2017 00:25

Like if it's input, can't you generate the input from forms? Like you have string in js with the root url

var rootUrl = "https://maps.googleapis.com/maps/api/geocode/json?address=";
var url = rootUrl + "your address from a form or something";

I guess idk how the location is dynamically changing.

Joseph
@Big-jo
Aug 08 2017 00:25
@zapcannon99 lol
and i dont think the error is my fault
i think i need to JSON.parse
it
Joel Y.
@zapcannon99
Aug 08 2017 00:27

Hmm, you're code is being done locally. Can't do much but speculate.

Just to make sure, you are getting the address from user input forms?

Joseph
@Big-jo
Aug 08 2017 00:27
yup
Joel Y.
@zapcannon99
Aug 08 2017 00:28

https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_submit

How about this example code? Will this help? In terms of dynamically changing the Url of course.

korzo
@korzo
Aug 08 2017 00:28
@Big-jo Json is correct for sure
Joel Y.
@zapcannon99
Aug 08 2017 00:29
Maybe not....
Let me find a better example.
Joseph
@Big-jo
Aug 08 2017 00:29
@korzo just trying to pass the blame
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:30

I am trying to do the Ceasar's Cipher challenge but I am getting a weird return:

function rot13(str) { // LBH QVQ VG!
  var arr = str.split("");
  for(x = 0; x < arr.length; x++) {
    if(arr[x].match(/[a-z]/i)) {
      arr[x] = arr[x].charCodeAt(0) - 13;
      arr[x] = String.fromCharCode(arr[x]);
    }

  }
  return arr;




}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

rot13("SERR PBQR PNZC"); is supposed to return FREE CODE CAMP, but instead it returns F8EE C5DE CAM6 (Once the array gets merged). Most of the letters are right, but sometimes there are numbers. Does anyone know why?

korzo
@korzo
Aug 08 2017 00:32
@jamesjpk123 because you have to either add or substract 13 depending on character
Joel Y.
@zapcannon99
Aug 08 2017 00:32
My guess is that when you are subtracting 13, you subtract too much and end up with a ASCII code that points to a numerical value when parsed back into a char
@jamesjpk123
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:33
@korzo, @zapcannon99 is there any way I can know when I either add/subtract?
korzo
@korzo
Aug 08 2017 00:33
@jamesjpk123 I think it's in description of challenge
Joel Y.
@zapcannon99
Aug 08 2017 00:34

@Big-jo

How about this thread. Dunno if this will help you.

James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:34

@korzo the challenge description isn't very helpful:
"A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.

Write a function which takes a ROT13 encoded string as input and returns a decoded string.

All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on."

Stephen James
@sjames1958gm
Aug 08 2017 00:35
@jamesjpk123 Also, the return is a string not an array
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:35
@sjames1958gm Oh I was going to code that in once I got the conversion done right
Joel Y.
@zapcannon99
Aug 08 2017 00:35
@jamesjpk123 What @korzo said. You could also look at the Ascii table and see when you need to do something other than just subtract 13.
Stephen James
@sjames1958gm
Aug 08 2017 00:35
@jamesjpk123 I saw that from the comment at the bottom - sorry
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:35
@sjames1958gm oh its fine
Joseph
@Big-jo
Aug 08 2017 00:36
@zapcannon99 thanks for your help and @korzo thanks too
CamperBot
@camperbot
Aug 08 2017 00:36
big-jo sends brownie points to @zapcannon99 and @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @korzo |http://www.freecodecamp.com/korzo
:cookie: 330 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Joel Y.
@zapcannon99
Aug 08 2017 00:36
Welcome. Let us know if things still don't work.
Tony Brackins
@mrbrackins
Aug 08 2017 00:37
@Big-jo var url = https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=${origin}&destinations=${destination}&key=${APIKEY};
this is what I used
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:39

@sjames1958gm, @zapcannon99, @korzo I decided to do this:

function rot13(str) { // LBH QVQ VG!
  var arr = str.split("");
  for(x = 0; x < arr.length; x++) {
    if(arr[x].match(/[a-z]/i)) {
      arr[x] = arr[x].charCodeAt(0) - 13;
      arr[x] = String.fromCharCode(arr[x]);
      if(arr[x].match(/[0-9]/)) {
        arr[x] = arr[x].charCodeAt(0) + 26;
      arr[x] = String.fromCharCode(arr[x]);
      }
    }


  }
  return arr;

And it works.
Thanks!

(Doing this do give points) Thanks @sjames1958gm @zapcannon99 @korzo for helping me out!
CamperBot
@camperbot
Aug 08 2017 00:40
jamesjpk123 sends brownie points to @sjames1958gm and @zapcannon99 and @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @korzo |http://www.freecodecamp.com/korzo
:cookie: 331 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
:star2: 8269 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:45
Oh there are some problems though. SERR YBIR? is FREE LO>E?
Stephen James
@sjames1958gm
Aug 08 2017 00:46
@jamesjpk123 You should adjust /[a-m]/i + 13 and /[n-z]/i by -13
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:46
Thanks @sjames1958gm
CamperBot
@camperbot
Aug 08 2017 00:46
jamesjpk123 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: jamesjpk123 already gave sjames1958gm points
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:51

Ok trying that with this code @sjames1958gm:

function rot13(str) { // LBH QVQ VG!
  var arr = str.split("");
  for(x = 0; x < arr.length; x++) {
    if(arr[x].match(/[a-m]/i)) {
      arr[x] = arr[x].charCodeAt(0) + 13;
      arr[x] = String.fromCharCode(arr[x]);
      if(arr[x].match(/[n-z]/i)) {
        arr[x] = arr[x].charCodeAt(0) - 13;
      arr[x] = String.fromCharCode(arr[x]);


    }
    }



  }
  str = arr.join("");
  return str;




}

For some reason, it passes the if statements as if they were nothing.

Stephen James
@sjames1958gm
Aug 08 2017 00:52
@jamesjpk123 Well your second if should be else if on the first one or you will just shift one way then the other
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:53
@sjames1958gm whoah, doing else if just solved the challenge!
Thank you so much!
Stephen James
@sjames1958gm
Aug 08 2017 00:53
@jamesjpk123 :+1:
James Patrick Kerrane
@jamesjpk123
Aug 08 2017 00:53
Time to clock off on my Habitica
One of my goals were to finish a challenge!
Joel Y.
@zapcannon99
Aug 08 2017 00:59
gj
Cory Hoban
@Khaladin
Aug 08 2017 01:58
Hello everyone, I've solved one of the coding problems but it doesn't pass the tests for some reason any ideas, I can post code
Lucci Paula
@luccipaula
Aug 08 2017 01:58
Hey guys, I just completed my Weather App and I'd appreciate some feedback on it! Today I spent several hours doing error handling and I think it's working well, hehe. :) https://codepen.io/vivalucci/full/mwgmGW/
Cory Hoban
@Khaladin
Aug 08 2017 01:59
var fib = [0,1];
function sumFibs(num) {

  var odds = [];
  var lastInArr = fib[fib.length - 1];
  var secondLast = fib[fib.length - 2];


  if (num === 1) {
    return 1;
  }
  if (num < lastInArr) {
    fib.pop();
    fib.map(function(val) {
      if (val % 2 != 0) {
        odds.push(val);
        }
    });
  }

   if (num >= lastInArr) {
     fib.push(lastInArr + secondLast);
     return sumFibs(num);
   }

  return odds.reduce(function (a ,b){
    return a + b;
  });


}

sumFibs(4);
@caixeta-paula Hey I think it looks fantastic, when I first pulled it up it had me as old seminole heights floida and there was no data but when I put in Tampa florida I got the icon and weather
Lucci Paula
@luccipaula
Aug 08 2017 02:01
Local Weather App.png
This is what I got :)
Oh I see what you mean
It geolocated incorrectly?
@Khaladin
Cory Hoban
@Khaladin
Aug 08 2017 02:02
Huh maybe it just took a second because it;s loaded fine now
No i geolocated very well
I guess there is no problem, It looks very asthetically pleasing too
Lucci Paula
@luccipaula
Aug 08 2017 02:03
@Khaladin Ah I see, yeah it's been taking a while to load from Dark Sky today, could be their server :P
@Khaladin Thank you!
CamperBot
@camperbot
Aug 08 2017 02:03
caixeta-paula sends brownie points to @khaladin :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @khaladin |http://www.freecodecamp.com/khaladin
Ryan Draves
@RyanDraves
Aug 08 2017 02:50
can anyone help with a basic react problem?
Christopher McCormack
@cmccormack
Aug 08 2017 03:14
@RyanDraves can try
Ryan Draves
@RyanDraves
Aug 08 2017 03:14
I'm all set now
Christopher McCormack
@cmccormack
Aug 08 2017 03:14
:thumbsup:
Ginger
@GingerChew
Aug 08 2017 03:36
is there any way in the console to see if a request is actually being made? (re the wikipedia search project)
Jim Tryon
@jimtryon
Aug 08 2017 03:38
I recommend postman for that
Brad
@bradtaniguchi
Aug 08 2017 04:10
@GingerChew (for chrome) you can check the network tab for all requests made.
clicking on a request shows the details, including the request, and response
I'm sure other browsers have similar features
Markus Kiili
@Masd925
Aug 08 2017 05:22
@Khaladin Global variable like that can mess up FCC tests.
jorlee92
@jorlee92
Aug 08 2017 05:42
Hey can anybody tell me what is wrong here??
It is part of my backend FCC assignment
For whatever reason I cant get it to output anything to the ser
*user. It just says
HPE_INVALID_CONSTANT: Request could not be proxied!
Markus Kiili
@Masd925
Aug 08 2017 05:47
Or the general chat if you don't get help there.
Maks Ushakov
@maks-ushakov
Aug 08 2017 06:18
@jorlee92 When you send response?
13391588897
@13391588897
Aug 08 2017 06:38
图片.png
who can help me
Brad
@bradtaniguchi
Aug 08 2017 06:40
@13391588897 Hi (what a name, if you are human)
WAINGOR
@WAINGOR
Aug 08 2017 06:41
@13391588897 I can help if you send me your code
13391588897
@13391588897
Aug 08 2017 06:42

function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for(var i=0; i<contacts.length; i++) {
if(contacts[i].firstName != firstName) {
return "No such contact";
} else if(contacts[i].prop != prop) {
return "No such property";
} else if(contacts[i].firstName == firstName && contacts[i].prop == prop) {
return contacts[i].prop;
}
}

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

// 你可以修改这一行来测试你的代码
lookUp("Akira", "likes");

@WAINGOR thanks
CamperBot
@camperbot
Aug 08 2017 06:42
13391588897 sends brownie points to @waingor :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @waingor |http://www.freecodecamp.com/waingor
WAINGOR
@WAINGOR
Aug 08 2017 06:43
OK first thing: please make sure to mark your code up with backticks: this is a backtick : `
Brad
@bradtaniguchi
Aug 08 2017 06:43
'''
CamperBot
@camperbot
Aug 08 2017 06:43
:bulb: to format code use backticks! ``` more info
WAINGOR
@WAINGOR
Aug 08 2017 06:43
@13391588897 place three backticks BEFORE and three backticks after your code
Markus Kiili
@Masd925
Aug 08 2017 06:45
@13391588897 You cannot return No such contact, if the first contact is not the one you look for. So the logic is wrong.
@13391588897 Also the property existence check should use hasOwnProperty or propertyIsEnumerable method.
13391588897
@13391588897
Aug 08 2017 06:47
__.png
Markus Kiili
@Masd925
Aug 08 2017 06:47
@13391588897 You only need two nested if's for the two conditions.
13391588897
@13391588897
Aug 08 2017 06:47
this question
js
WAINGOR
@WAINGOR
Aug 08 2017 06:48
yes @13391588897 the way your logic is structured will make it return false too early.. Make sure you scan ALL contacts... if NONE of them match the name provided, only then can you return "no such contacts"
13391588897
@13391588897
Aug 08 2017 06:48
ok thanks very much
WAINGOR
@WAINGOR
Aug 08 2017 06:48
a way to check such a condition is to place an if statement AFTER the entire for in loop :)
for loop I mean * this is a good way because you will know that the loop has checked each and every item
Markus Kiili
@Masd925
Aug 08 2017 06:50
@WAINGOR No if's are needed after the loop. Two nested if's inside the loop block is enough.
WAINGOR
@WAINGOR
Aug 08 2017 06:53
@Masd925 can you perhaps show me what you mean? I wouldnt know how to write it as you put it :)
I am curious to see, because the only way I would know to check within the for loop is to say: if (i==contacts.length-1)
Markus Kiili
@Masd925
Aug 08 2017 06:55
@WAINGOR I mean that the simplest solution is two nested if's for the first name and property existence checks and then only the returns on correct spots. After the loop block you can just make a return.
WAINGOR
@WAINGOR
Aug 08 2017 06:55
could you send it to me in a pm? or write it here in code?
Markus Kiili
@Masd925
Aug 08 2017 06:56
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i<contacts.length; i++) {
    if (contacts[i].firstName===firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
If the loop runs out, there was no contact with given first name.
@WAINGOR
WAINGOR
@WAINGOR
Aug 08 2017 07:02
@Masd925 lol I am a bit confused myself now when making this assignment. First of all: how does JS know that by contacts[i].firstName you mean the property named firstName of the object, and not the first parameter of the function?
Markus Kiili
@Masd925
Aug 08 2017 07:04
@WAINGOR Just firstName makes JS look for a variable with that name i.e the parameter here. If you use syntax obj.key or obj[key] or obj.hasOwnProperty(key) JS automatically looks for a property key.
WAINGOR
@WAINGOR
Aug 08 2017 07:07
aaah OK I never knew... thanks @Masd925
CamperBot
@camperbot
Aug 08 2017 07:07
waingor sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4385 | @masd925 |http://www.freecodecamp.com/masd925
Tai Jones
@taiJones00
Aug 08 2017 07:31
I just got to the build a random quote machine project. No idea where to start on this
Markus Kiili
@Masd925
Aug 08 2017 07:36
@taiJones00 You will learn the most if you find an web api that provides random quotes.
Then some code that binds some user action to an ajax request that gets the quote response and shows it at the page.
Tai Jones
@taiJones00
Aug 08 2017 07:38
Arigato @Masd925
CamperBot
@camperbot
Aug 08 2017 07:38
taijones00 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4386 | @masd925 |http://www.freecodecamp.com/masd925
Blauelf
@Blauelf
Aug 08 2017 08:05
Good morning :wave:
@camperbot understands Japanese (at least in rōmaji)?
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:08
good morning everyone
Blauelf
@Blauelf
Aug 08 2017 08:09
@camperbot どうもありがとうございます。
Won't understand "thanks" in hiragana. (that's more like "thank you very much", but still... @camperbot does not seem to actually understand Japanese, just the "arigato" phrase)
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:14
https://codepen.io/tiagocorreia/pen/VzKxeb is there anyway to avoid what's happening everytime I click on a box?If I have content on therm before clicking I have no problem but if they are clean this change of place
Bartosz
@CataciD
Aug 08 2017 08:15
If you mean the shifting id guess lineheight would fix that
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:17
im using line-height on the col is that what you mean?
Bartosz
@CataciD
Aug 08 2017 08:18
im not sure, but my first guess would be setting line-height in all the places where you put in X / O should be 0
but htats just a wild guess
i never had that kind of thing happen to me
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:18
doesnt works :p its kinda confusing
cause if you have 2 in a line
the problem stops
but if you have only 1 x or 0
the problem is there
WAINGOR
@WAINGOR
Aug 08 2017 08:20
Hi all, I have a basic question: does return ALWAYS end the loop in a for loop?
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:21
yeah
Markus Kiili
@Masd925
Aug 08 2017 08:21
@WAINGOR If a return statement is executed, then the loop and function terminates.
WAINGOR
@WAINGOR
Aug 08 2017 08:21
Allright, thanks @tiagocorreiaalmeida and @Masd925
CamperBot
@camperbot
Aug 08 2017 08:21
waingor sends brownie points to @tiagocorreiaalmeida and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
:star2: 4387 | @masd925 |http://www.freecodecamp.com/masd925
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:22
@Masd925 can you give a look into the pen I sent before?if possible confusing things happening :D
Bartosz
@CataciD
Aug 08 2017 08:22
im looking at it and i dunno
it seems inline-block is messing with something
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:22
@CataciD confusing right?
Bartosz
@CataciD
Aug 08 2017 08:23
also i'd figure it would be good to have the board in a single container
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:23
that's right, done eheh
still the problem is there boring, anyway thanks for having a look into it
Bartosz
@CataciD
Aug 08 2017 08:24
?
i didnt understand
whats the problem? :P
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:25
you were right in creating a content div for all the board, but the problem of clicking and the css goign crazy stills there xd
Bartosz
@CataciD
Aug 08 2017 08:28
vertical-align:middle;
this is what you need
cause its the text thats aligned to top
but has space around it
thats why it buggs out
add that to .col and you're fine
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:30
@CataciD only that mate?cause still looks kinda crazy eehhe doesnt move when clicking but its kinda bad placed with no sense
nm
solvedhad a little mistake big thanks @CataciD
CamperBot
@camperbot
Aug 08 2017 08:31
tiagocorreiaalmeida sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @catacid |http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Aug 08 2017 08:31
well the movement was the problem
tbh all that inline shit is ancient to me
i use flex eclusively foro positioning
works best
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:31
I could have used bootstrap aswell here but np all cool eheh
thanks once again
Bartosz
@CataciD
Aug 08 2017 08:32
yeah well bootstrap is fine aswell
though i ditched it aswell
in favor of flex
its literally so simple
tell flex you want it flexed, every thing is supposed to be 100px, in the center and vertically aligned in middle
and wrap after 3
ezpzp
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:33
ok lets try to change this into flex, always interested in learning
bootstrap v4 is currently using flex I think
take a look for inspiration
this was done in like 30 min
never finished it
but it has all the flex proper
and should scale to any size
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:36
as far as I understood need to place this on my container display:flex;
flex-wrap:wrap;
justify-content:center;
align-items:center; right?
Bartosz
@CataciD
Aug 08 2017 08:38
mostly
you can checkup flexbox.io
if you're interested
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:38
Bartosz
@CataciD
Aug 08 2017 08:38
but for that to work you need to also specify sizes
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:38
if you do this, you won't need to ask questions about flex ever
Bartosz
@CataciD
Aug 08 2017 08:38
or at least minimum sizes
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:38
highly recommend it @tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:38
thanks @abhinav-thinktank
CamperBot
@camperbot
Aug 08 2017 08:38
tiagocorreiaalmeida sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:cookie: 484 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:39
it's a bit long though
but worth it
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:39
@CataciD https://codepen.io/tiagocorreia/pen/VzKxeb got this can you just if Im not writting not needed thigns?
np will give it a look for sure
Bartosz
@CataciD
Aug 08 2017 08:39
you dont need flex in the body
i use flex in body to center 1 container
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:40
was a error
it was omn the container
xd
Bartosz
@CataciD
Aug 08 2017 08:40
like if i have 1 div in the whole body
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:40
.container{
flex-direction:column;
justify-content:center;
align-items:center;
}
this
Bartosz
@CataciD
Aug 08 2017 08:40
and i want that div to be dead center
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:40
but in this would only need it on the row right?
Bartosz
@CataciD
Aug 08 2017 08:40
yeah but for flex/flexwrap
you dont need rows
if you're using rows
then wrap is not needed
flex-wrap wraps boxes
if the next one doesnt fit
it puts it below
i had 9 boxes in a line, container width that could hold 3
so my flexbox wrapped
and put 4th below etc
if you have manually written rows
you can just tell him to flex to 1/3 of the width of the row
becuse it self is a container
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:42
confusing maybe will look into the link that was sent to me thanks @CataciD for using your time teaching me :)
CamperBot
@camperbot
Aug 08 2017 08:42
tiagocorreiaalmeida sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:warning: tiagocorreiaalmeida already gave catacid points
Bartosz
@CataciD
Aug 08 2017 08:42
and the main container should flex-directin:column since your rows are from top to bottom
ye read up
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:42
@tiagocorreiaalmeida go for it!
Bartosz
@CataciD
Aug 08 2017 08:42
its really good once you understand how it works
i will probably never touch anything else
no point in using bootstrap or whatnots
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:43
it does say for free but after 225 dolars so is it really free?xd
ahahaha cool cause I dont like bootstrap that much half of the tiems you have to overwrite some of their css
but some people seems to love it
@abhinav-thinktank free or ?.D
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:44
free
it says it's valued at 225
and i think it is
it's a pretty fun way of learning flex, and will make your fundamentals quite strong
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:45
ok mate thanks :)
probably should finish this frontend project before but lets jump into it :D
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:45
also, from what i've heard flex is good for making smaller stuff responsive
but for more complex projects you will need css grid too
or Bootstrap
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 08:54
@abhinav-thinktank do you know any website where you can kinda "Master" css aswell?cause writing a few lines of css after 1 week everyone can do it I think but doing it really properly its other thing
Abhinav Mishra
@abhinav-m
Aug 08 2017 08:54
@tiagocorreiaalmeida nah..
what i like to do is if a learn new css stuff, i make a few samples of it
just to get a hang of it
css-tricks has some good reference material
if you wanna look up stuff
bilaal-s
@bilaal-s
Aug 08 2017 09:10
hello guys rookie question: https://codepen.io/bilaal-s/pen/QMjVKK?editors=1111 ,why does $("#plus").hasClass("operation"); return false even though i do have an a tag with id plus and it does have a class operation??
I have loaded jquery
Bartosz
@CataciD
Aug 08 2017 09:13
hasClass
id plus
wait
nvm went retard
gonna check code
Abhinav Mishra
@abhinav-m
Aug 08 2017 09:13
@bilaal-s cant see the hasClass in your code
Bartosz
@CataciD
Aug 08 2017 09:13
also that
bilaal-s
@bilaal-s
Aug 08 2017 09:14
@abhinav-thinktank sorry i ran it in console
it returns false
Bartosz
@CataciD
Aug 08 2017 09:14
class="button"
has only this
bilaal-s
@bilaal-s
Aug 08 2017 09:15
@CataciD what do you mean? thats the only class that #plus has?
Bartosz
@CataciD
Aug 08 2017 09:15
<a class="button" id="plus">+</a>
wheres the operator
class
i dont see it
Abhinav Mishra
@abhinav-m
Aug 08 2017 09:15
class="button" class="operation"
seperate classes by a space
class ="button operation"
bilaal-s
@bilaal-s
Aug 08 2017 09:16
<a class="button" class="operation" id=plus>+</a>
Bartosz
@CataciD
Aug 08 2017 09:16
should be class="button operator"
bilaal-s
@bilaal-s
Aug 08 2017 09:16
ooooooooooooooooooooohhhhhhhhhhhhhhhhhhhhhh
Bartosz
@CataciD
Aug 08 2017 09:16
you cant have two class= declaration
its like chaing variable
bilaal-s
@bilaal-s
Aug 08 2017 09:16
I see, wow xD thanks guys @CataciD @abhinav-thinktank
CamperBot
@camperbot
Aug 08 2017 09:16
bilaal-s sends brownie points to @catacid and @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @catacid |http://www.freecodecamp.com/catacid
:cookie: 485 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
Bartosz
@CataciD
Aug 08 2017 09:16
inspect your code
bilaal-s
@bilaal-s
Aug 08 2017 09:16
to think im doing advanced projects without knowing that >.>
Bartosz
@CataciD
Aug 08 2017 09:16
dont look at what you wrote ;lP
but what renders
bilaal-s
@bilaal-s
Aug 08 2017 09:16
@CataciD how do i check what it renders?
Bartosz
@CataciD
Aug 08 2017 09:16
chill
bilaal-s
@bilaal-s
Aug 08 2017 09:17
source code?
Bartosz
@CataciD
Aug 08 2017 09:17
right click
inspect
you got a console there
and the source html
there is no class="operator"
bilaal-s
@bilaal-s
Aug 08 2017 09:17
ahhhhhhh
Bartosz
@CataciD
Aug 08 2017 09:17
in there
bilaal-s
@bilaal-s
Aug 08 2017 09:17
@CataciD :thumbsup:
Markus Kiili
@Masd925
Aug 08 2017 09:19
@bilaal-s It causes parse error and the second class attribute is ignored.
bilaal-s
@bilaal-s
Aug 08 2017 09:21
@Masd925 Didnt know haha, I knew something was wrong as the syntax should have been right.
Bartosz
@CataciD
Aug 08 2017 09:22
yeah in general remember class= is literally a variable of the dom
and it can hold multiple classes
so class="column shit cuck lulz"
Abhinav Mishra
@abhinav-m
Aug 08 2017 09:24
@bilaal-s It causes parse error and the second class attribute is ignored.
cykins4good
@cykins4good
Aug 08 2017 09:34
Make Instances of Objects with a Constructor Function   freeCodeCamp.jpg
Hi to you all.I was asked to use the Car constructor to create a new instance and assign it to myCar.Then give myCar a nickname property with a string value.This is my code which i believe is wrong.
Markus Kiili
@Masd925
Aug 08 2017 09:36
@cykins4good You need to use myCar variable that holds the new car. Don't write any new functions or literals.
cykins4good
@cykins4good
Aug 08 2017 09:42
Make Instances of Objects with a Constructor Function   freeCodeCamp-1.jpg
@Masd925 i came up with this but not going through
Markus Kiili
@Masd925
Aug 08 2017 09:43
@cykins4good What was the property key you needed to create?
cykins4good
@cykins4good
Aug 08 2017 09:45
@Masd925 i was told to use the Car constructor to create a new instance and assign it to myCar.Then give myCar a nickname property with a string value.
Markus Kiili
@Masd925
Aug 08 2017 09:46
@cykins4good For creating nickname property, you need to do obj.nickname = ... for the object in question.
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 10:04
hey everyone im doing the tic tac toe challenge this is my pen https://codepen.io/tiagocorreia/pen/VzKxeb?editors=0010 im having some issues on creatign the computer moves
so I checked out a tutorial and im aswell checking this website https://lodash.com/ cause there's new things on the code that I didnt knew somehow im getting a error if you can check
Stephen James
@sjames1958gm
Aug 08 2017 10:14
@cykins4good a new instance is created by
var myCar = new Car();
This creates a new empty object and calls the Car function. Then inside the Car function this is that new object created
then myCar is assign that object.
@tiagocorreiaalmeida Looks like you are trying to use lodash, but I don't see where you include it?
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 10:17
Uncaught RangeError: Maximum call stack size exceeded
at At (lodash-fp.min.js:43)
at lodash-fp.min.js:44
at et (lodash-fp.min.js:40)
at At (lodash-fp.min.js:44)
at lodash-fp.min.js:44
at et (lodash-fp.min.js:40)
at At (lodash-fp.min.js:44)
at Function.Oo [as cloneDeep] (lodash-fp.min.js:88)
at minmax (pen.js:69)
at minmax (pen.js:72)
Stephen James
@sjames1958gm
Aug 08 2017 10:19
@tiagocorreiaalmeida if(gridCopy[i][j] !== ''){ this check seems odd -
Should that be === '' to check for empty cell?
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 10:24
this is what the tutorial I checked has
image.png
im missing continue
Stephen James
@sjames1958gm
Aug 08 2017 10:26
so continue there has the same result as === ''
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 10:26
yeah I know :P
so no need to write that but only a normal if statement
Jefferson
@jeffersonnnn
Aug 08 2017 10:27
Hi guys, i am looking for a tips on the Chunky Monkey bonfire, please. Can i get any? Here is my code

function chunkArrayInGroups(arr, size) {
  var chunky = [];
  var wC = 0;
  while (wC < arr.length) {
    wC++;
    arr.splice(size);

  }

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
at least, that is my code so far.
Markus Kiili
@Masd925
Aug 08 2017 10:28
@jeffersonnnn With a while loop you could splice size elements from the start as long as there are elements left on arr, and push return value of splice into result array.
Return value of splice is a new array made from removed elements.
Stephen James
@sjames1958gm
Aug 08 2017 10:29
@jeffersonnnn realize that splice will reduce the size of arr, so your check on the while could be arr.length > 0
kumquatfelafel
@kumquatfelafel
Aug 08 2017 10:30
splice won't do anything as written since there's no deletion occurring.
Jefferson
@jeffersonnnn
Aug 08 2017 10:33
@sjames1958gm will do. My he
@sjames1958gm @kumquatfelafel @Masd925 thanks people. I know i can do this.
CamperBot
@camperbot
Aug 08 2017 10:34
:cookie: 580 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 8270 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
jeffersonnnn sends brownie points to @sjames1958gm and @kumquatfelafel and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4388 | @masd925 |http://www.freecodecamp.com/masd925
Stephen James
@sjames1958gm
Aug 08 2017 10:44
@jeffersonnnn :+1:
pramod goyal
@nightraven112
Aug 08 2017 10:51

function findLongestWord(str) {
var words = str.split(' ');
var maxLength = 0;

for (var i = 0; i < words.length; i++) {
if (words[i].length > maxLength) {
maxLength = words[i].length;
}
}

return maxLength;
}

i cant understand this code
and i feel really bad
heroiczero
@heroiczero
Aug 08 2017 10:55
@nightraven112 what don't you understand
@nightraven112 You are given a str string and you want to find the largest word in the string, so you split the str into separate words and find the largest word by checking if the current word is larger than previous words. You can also do this in reduce.
Markus Kiili
@Masd925
Aug 08 2017 10:59
@nightraven112 maxLength holds the longest word length found so far and after the loop it will be the length of the longest word.
Abid Rahim
@abidRahim
Aug 08 2017 11:10

code for: seek and destroy

` var here = arr.filter( function(val){
for (var i=0; i<arguments.length; i++)
{
if (val == arguments[i])
return false;
}
return true;
});

return here;

}`

what am i doing wrong here?

`
function destroyer(arr) {
// Remove all the values

var here = arr.filter( function(val){
for (var i=0; i<arguments.length; i++)
{
if (val == arguments[i])
return false;
}
return true;
});
return here;
}`

Markus Kiili
@Masd925
Aug 08 2017 11:12
@abidRahim true needs to be returned after the for loop block.
Abid Rahim
@abidRahim
Aug 08 2017 11:12
okay i'll try now
Markus Kiili
@Masd925
Aug 08 2017 11:12
Filter callback function also has its own arguments object.
heroiczero
@heroiczero
Aug 08 2017 11:12
@abidRahim arguments[0] is your array
Markus Kiili
@Masd925
Aug 08 2017 11:14
@abidRahim You can store destroyers arguments object into a variable, turn it into an array, or pass it into the callback function as this using the filter methods thisArg syntax.
Abid Rahim
@abidRahim
Aug 08 2017 11:14
how?
Markus Kiili
@Masd925
Aug 08 2017 11:15
@abidRahim If you do var args = arguments; you can then use args inside the callback. It will hold all the arguments passed into destroyer.
Ryan Williams
@Ryanwfile
Aug 08 2017 11:25
In React I have a grid created from an array, on the <td> elements I have an
onClick ={() => console.log(cellValue)}
which works perfectly when I click a td the console shows the cell number, however if I try and change the console.log to another function I can’t seem to get the function executed no matter how I bind its this value. I have the function bound in the constructor function as this.setBoard = this.setBoard.bind(this); Any help getting a function to be invoked on a td click would be greatly appreciated.
Bartosz
@CataciD
Aug 08 2017 11:28
how do you put the function in it?
cykins4good
@cykins4good
Aug 08 2017 11:30
Make Instances of Objects with a Constructor Function   freeCodeCamp.jpg
@Masd925 , @sjames1958gm Thanks a lot.i did finally solved it.And this is my solution.
CamperBot
@camperbot
Aug 08 2017 11:31
cykins4good sends brownie points to @masd925 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8271 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 4389 | @masd925 |http://www.freecodecamp.com/masd925
Abid Rahim
@abidRahim
Aug 08 2017 11:31

@Masd925 is my logic correct?

i would want to filter out the elements by runnning a loop on the number of arguments starting from 1.
If that argument is same as the value of 0th argument or 'arr', then i would want to discard it.

Ryan Williams
@Ryanwfile
Aug 08 2017 11:32
@CataciD I have tried a lot of different ways such as
```
onClick ={() => this.setBoard()}
onClick ={this.setBoard()}
Markus Kiili
@Masd925
Aug 08 2017 11:33
@abidRahim Filter loops arr elements automatically, so inside the filter callback, you need to loop the destroyers arguments (from index 1) and see if there is an argument equal to the filter callback parameter.
So your code is close.
Just loop destroyers arguments and not the callback functions arguments and remember to return true after the loop.
Abhinav Mishra
@abhinav-m
Aug 08 2017 11:36
Hey guys
a very generic question:
I want to practice and improve upon javascript's concepts
like scopes inheritance
improve as in*
are there exercises / courses i can follow somewhere to do this
heroiczero
@heroiczero
Aug 08 2017 11:38
@abhinav-thinktank Codewars to do javascript exercises
@abhinav-thinktank https://www.codewars.com/
Abhinav Mishra
@abhinav-m
Aug 08 2017 11:40
@heroiczero ty!
Bartosz
@CataciD
Aug 08 2017 12:04
@Ryanwfile you need to figure out how this works
this in general refers to the outer element but with react its kinda funny
cause the function onClick actually needs to return the function that would be in the html
and if that function has "this" in it, it reffers to null or something funny
from what i understand
so you would need to have a function using this in the parent component, that returns a function returning that value
without reffering to "this" in that last function
also doing onclick=functionName() will pass the result of the function into the onclick not the function itsself
Ryan Williams
@Ryanwfile
Aug 08 2017 12:08
@CataciD thanks for the help
CamperBot
@camperbot
Aug 08 2017 12:08
ryanwfile sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:cookie: 415 | @catacid |http://www.freecodecamp.com/catacid
Ryan Williams
@Ryanwfile
Aug 08 2017 12:09
@CataciD Thanks, I got it working now
cykins4good
@cykins4good
Aug 08 2017 12:12
Make Unique Objects by Passing Parameters to our Constructor   freeCodeCamp.jpg
Hi to you all.i was asked to alter the Car constructor to use parameters to assign values to the wheels, seats, and engines properties.Thereafter, i should call my new constructor with three number arguments and assign it to myCar to see it in action.This i have done, but the system is not passing me.Please what might have gone wrong?
Adnan Karšić
@adokce
Aug 08 2017 12:13
hello, i need help with a javascript algorithm challenge
Markus Kiili
@Masd925
Aug 08 2017 12:13
@cykins4good Use capital C on Car. You are using new car.
Bartosz
@CataciD
Aug 08 2017 12:13
post it in <shift+enter>
Adnan Karšić
@adokce
Aug 08 2017 12:13
aa
okay
Bartosz
@CataciD
Aug 08 2017 12:14
start with '```'
code inside and end the same
Adnan Karšić
@adokce
Aug 08 2017 12:14
https://www.freecodecamp.org/challenges/chunky-monkey
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  var j =0,k=0;
  for (var i=0;i<arr.size;i++){
    newArr[j][k]=arr[i];
//     j = (k==1) ? +1 : +0;
//     k = (k<2) ? +1 : 0;
    if (k==1) j++;
    if (k<2) k++;
    else k=0;
  }
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Bartosz
@CataciD
Aug 08 2017 12:14
ok what do you have a problem with
Adnan Karšić
@adokce
Aug 08 2017 12:14
i am doing something wrong with newArr
and it returns empty array
Bartosz
@CataciD
Aug 08 2017 12:14
what are you supposed to do?
Adnan Karšić
@adokce
Aug 08 2017 12:15
i am suposed to chunk array
and return 2 dimensional array
Bartosz
@CataciD
Aug 08 2017 12:15
arr.size
in the for loop
Adnan Karšić
@adokce
Aug 08 2017 12:15
damn
haha
thanks
Bartosz
@CataciD
Aug 08 2017 12:15
np
Adnan Karšić
@adokce
Aug 08 2017 12:15
but it looks like it still doesnt work
Bartosz
@CataciD
Aug 08 2017 12:15
then its one mistake
Adnan Karšić
@adokce
Aug 08 2017 12:15
let me see for a sec
Bartosz
@CataciD
Aug 08 2017 12:16
lets go on
it should be size in the for
Adnan Karšić
@adokce
Aug 08 2017 12:16
hmm
are you sure
so
i may need nested for loop
?
Bartosz
@CataciD
Aug 08 2017 12:17
you're kinda overcomplicating things with this i think
yep
Adnan Karšić
@adokce
Aug 08 2017 12:17
i tried to do this with .map
Bartosz
@CataciD
Aug 08 2017 12:17
a nested one would do fine
Adnan Karšić
@adokce
Aug 08 2017 12:17
but i cant grasp my head around it right now
Bartosz
@CataciD
Aug 08 2017 12:17
logically
you want your function to make chunks of 2
cykins4good
@cykins4good
Aug 08 2017 12:17
@Masd925 Thanks alot.After i did changed the car to capital C,the system passed me.
CamperBot
@camperbot
Aug 08 2017 12:17
cykins4good sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: cykins4good already gave masd925 points
Bartosz
@CataciD
Aug 08 2017 12:17
so every two arguments you want to start a new chunk
or rather every new "size" start a chunk
Adnan Karšić
@adokce
Aug 08 2017 12:17
yeah
makes sense
Bartosz
@CataciD
Aug 08 2017 12:18
so i dunno if you even need a nested one
also do you know array methods?
they're extremely usefull in this kind of scenario
things like array.splice() array.slice()
Adnan Karšić
@adokce
Aug 08 2017 12:19
i'm going to try these things now
thanks @CataciD
CamperBot
@camperbot
Aug 08 2017 12:19
adokce sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
Bartosz
@CataciD
Aug 08 2017 12:19
also
CamperBot
@camperbot
Aug 08 2017 12:19
:cookie: 416 | @catacid |http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Aug 08 2017 12:19
you're trying to make an array by passing and controlling indexes
which is really pointless
theres a thing array.push()
Adnan Karšić
@adokce
Aug 08 2017 12:19
it's better to use push
Bartosz
@CataciD
Aug 08 2017 12:19
which literally adds anything you give it to the end of an array
yeah
so you can just make it so
Adnan Karšić
@adokce
Aug 08 2017 12:20
damn, old habits die hard
Bartosz
@CataciD
Aug 08 2017 12:20
yep
so just try to split the arrays in twos
and push those
Adnan Karšić
@adokce
Aug 08 2017 12:20
we were tought in school to use indexes
Bartosz
@CataciD
Aug 08 2017 12:20
fuck that
i mean
you can
but theres no point here
why do you care what index it has?
Adnan Karšić
@adokce
Aug 08 2017 12:21
and these built in functions arent that natural for me..
yet
Bartosz
@CataciD
Aug 08 2017 12:21
yeah you should learn them by heart tbh
they'll save you a ton of work
but in general in this case you could only use push
Adnan Karšić
@adokce
Aug 08 2017 12:21
okay, i'm going to try and practice now
actually
wait
Bartosz
@CataciD
Aug 08 2017 12:21
go a head
Adnan Karšić
@adokce
Aug 08 2017 12:21
if it's two dimensional array
how does push work
Bartosz
@CataciD
Aug 08 2017 12:21
yep
push is attached to the array you want to push into
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:22
Depends on where you want to push to
Bartosz
@CataciD
Aug 08 2017 12:22
so lets say you have array1
and you want it to have array2 inside
array1.push(array2)
does that
Adnan Karšić
@adokce
Aug 08 2017 12:22
aaaa
Bartosz
@CataciD
Aug 08 2017 12:22
and now if you want to have shit in array2
array2.push(a)
Adnan Karšić
@adokce
Aug 08 2017 12:22
yes
Bartosz
@CataciD
Aug 08 2017 12:22
that way you end up with array1 = [[a]]
Adnan Karšić
@adokce
Aug 08 2017 12:22
thank you
Bartosz
@CataciD
Aug 08 2017 12:22
np
Adnan Karšić
@adokce
Aug 08 2017 12:22
so i need 'temporary' array array2
Bartosz
@CataciD
Aug 08 2017 12:22
thats because those are array methods
not really
Adnan Karšić
@adokce
Aug 08 2017 12:23
that gets pushd in
array1
Bartosz
@CataciD
Aug 08 2017 12:23
i mean you can yeah
lets say you make a temp array
and every step in a for loop you check its length
if the length is 2
push and restart array
Adnan Karšić
@adokce
Aug 08 2017 12:23
okay, going to try that now
Bartosz
@CataciD
Aug 08 2017 12:24
get one, push it into array, check length? is it 2 or more? empty it
gogo
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:26
just keep in mind when coding that the length of the chunks you want won't necessarily be 2 though.
Bartosz
@CataciD
Aug 08 2017 12:26
yeah he kinda got that part
in code
as the size var
so i believe in him xP
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:31

speaking of size....

for (....;i<arr.size;....){

This condition check is basically saying "if i is less than the value of size property in arr, then keep looping."

Array has no "size" property, though it does have a length property. If you meant to refer to the size from parameter, just say size, not arr.size. If you meant for it to refer to the length of the array, then use arr.length.

@adokce
Adnan Karšić
@adokce
Aug 08 2017 12:32
yes, i mixed these 2
i meant length
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 12:33
hey
https://codepen.io/tiagocorreia/pen/VzKxeb?editors=0110 can someone check my pen? got a little problem my code doesnt get into line 65 that's why I get an undefined cost as error if anyone has idea what im missing or doign wrong for it doesnt go further
Bartosz
@CataciD
Aug 08 2017 12:36
mate did you copy this piece of code from somewhere
or is this some funky library
never saw anyone writing _.something
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:37
lodash
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 12:37
just saw about it today
yeah on a tutorial
and yes lodash
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:37
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 12:37
cause I could do the computer Turn with tons of if statement
butthat didnt seem the right way so I stopped when I had it almost done
but I allready had around 120 lines
so no sense in keep going that way
@kumquatfelafel do you have any idea what im missing?hum
Abhijeet Singh
@abhijeetps
Aug 08 2017 12:41
Hey guys, I built this website http://www.iiitt.ac.in/.
Please explore it and give reviews.
Also, I am planning to add a Content Management System (CMS).
I recently explored http://keystonejs.com/. Would anybody provide me a review of it and tell me more about it?
Adnan Karšić
@adokce
Aug 08 2017 12:41
@kumquatfelafel and @CataciD
just want to let you guys know i finished the challenge and code looks like this now:

function chunkArrayInGroups(arr, size) {
  var first, last = size;
  var newArr=[];
  for (var i=0; i<arr.length/size;i++){
    var temp = [];
    temp = arr.slice(first, last);
    newArr.push(temp);
    first = last;
    last += size;
  }
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
do you have any refactor ideas to improve it
Markus Kiili
@Masd925
Aug 08 2017 12:43
@adokce If you increment the index by i+=size, you can just push slices into result array. No other variables needed.
Tao
@zombiebirds
Aug 08 2017 12:43

function titleCase(str) {
// 请把你的代码写在这里
var words = str.split(" ");
var word;
for(i=0 ;i<words.length ; i++){
word = words[i].split("");
for(j=0;j<word.length;j++){
var letter = word[j];
if(j === 0){
letter.toUpperCase();}
else{
letter.toLowerCase();
}
}
}
return str;
}

titleCase("I'm a little tea pot");
Why is it invalid?

kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:44
@tiagocorreiaalmeida will take a little look see, but kinda tired. Is problem that computer never moves?
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 12:44
yeah cause if you open console it will say taht "cost is not defined"
so it never runs this
   values.push({
              cost: value,
              cell: {
                i: i,
                j: j
              }
            });
Adnan Karšić
@adokce
Aug 08 2017 12:45
@Masd925 i placed i+=size and removed divider /size and it works too
which variables you ment ?
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:46
@zombiebirds toUpperCase returns a new string, it does not modify the original. Same for toLowerCase. This is because strings are immutable.
Thus, you're getting a bunch of new letters, but not storing them anywhere.
Markus Kiili
@Masd925
Aug 08 2017 12:47
@adokce I mean that you can do it like this:
function chunkArrayInGroups(arr, size) {
  var result = [];
  for (var i=0; i<arr.length; i+=size) {
    result.push(arr.slice(i,i+size));
  }
  return result;
}
Chris Juchtmans
@kjuchtmans
Aug 08 2017 12:47
afternoon coders! :wave:
Adnan Karšić
@adokce
Aug 08 2017 12:49
holy shit @Masd925 thanks
CamperBot
@camperbot
Aug 08 2017 12:49
adokce sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4391 | @masd925 |http://www.freecodecamp.com/masd925
kumquatfelafel
@kumquatfelafel
Aug 08 2017 12:49
Going along with the whole strings are immutable theme, str.split(" ") will return a new array. Playing around with the values stored in this array will not modify the original string either. So when you say return str; in the end, you are actually just returning the same string that was passed in originally. @zombiebirds
Chris Juchtmans
@kjuchtmans
Aug 08 2017 12:51
Speculative rather than technical question:
As one progresses toward front end certificate, is it advisable / habitual to move from imperative to more declarative syntax?
What I mean is: as I start to appreciate the likes of map, reduce ...spread operator, const/let, set etc for succinctness and light weight, I wonder whether readibility suffers?
Any personal opinions welcome!
WAINGOR
@WAINGOR
Aug 08 2017 12:53

Hi all, I have a question. Suppose we would have:

var X = { };
var Y =  "name";

And I would want to assign Y (so "name") to X as a property with a value of "John" . When I try X.Y or X[Y] is just outputs X {Y:"John"}; How can I get around this?

Markus Kiili
@Masd925
Aug 08 2017 12:54
@kjuchtmans JS is a multi-paradigm language and most things can be done with any of the paradigms. Most important thing is that the code is clear.
WAINGOR
@WAINGOR
Aug 08 2017 12:54
so to be clear I want the result to be X === { name : "John"};
Markus Kiili
@Masd925
Aug 08 2017 12:55
@WAINGOR X[Y] = "John";
Bracket notation evaluates the expression inside the brackets into a string and uses it as property key.
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 12:55
@kumquatfelafel did you had time to check it ?eheh
Chris Juchtmans
@kjuchtmans
Aug 08 2017 12:55
@Masd925 so what is your general preference, a more declarative style of more imperative, sir?
Abhijeet Singh
@abhijeetps
Aug 08 2017 12:56
Hey @/all I built this website http://www.iiitt.ac.in/.
Please explore it and give reviews.
Also, I am planning to add a Content Management System (CMS).
I recently explored http://keystonejs.com/. Would anybody provide me a review of it and tell me more about it?
Tao
@zombiebirds
Aug 08 2017 12:56
@kumquatfelafel OK, I see
WAINGOR
@WAINGOR
Aug 08 2017 12:57
thanks @Masd925
CamperBot
@camperbot
Aug 08 2017 12:57
waingor sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4392 | @masd925 |http://www.freecodecamp.com/masd925
WAINGOR
@WAINGOR
Aug 08 2017 12:57
@Masd925 you're restless!
<3
Markus Kiili
@Masd925
Aug 08 2017 13:02
@kjuchtmans I think I like all the paradigms. In JS I just try to keep the code clear. I am not a knight yet, so stop calling me sir.
;)
Saikat-Sinha
@Saikat-Sinha
Aug 08 2017 13:29
How to create an intro to the web app (on boarding users to the application)
similar to slack when joining for the first time.
A small hint will also be enough..
kumquatfelafel
@kumquatfelafel
Aug 08 2017 13:33

@tiagocorreiaalmeida Your minmax is messed up. Add this console.log(gridCopy); just after var gridCopy = _.cloneDeep(newGrid);

Note what happens in console. Keeps adding X and O alternatively to grid, recursively calling minmax without ever running values.push. Finally, when grid is entirely filled, this triggers a null return from game over function.

Thus, in turn, when status is null, it no longer === false, which prevents function from calling itself recursively again (took a moment to figure out why this wasn't infinite recursion). Thus moving onto if(player === computerMark), which is a satisfied condition so...
kumquatfelafel
@kumquatfelafel
Aug 08 2017 13:39

when we move on to this, cost has never been defined.

var max = _.maxBy(values, (v) => {
   return v.cost;
});

@tiagocorreiaalmeida

kumquatfelafel
@kumquatfelafel
Aug 08 2017 13:47

(because values.push() was never called)

Off for now.

Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 13:49
thanks for taking a look into it got myself consufed will see what I can do :p
kumquatfelafel
@kumquatfelafel
Aug 08 2017 13:50
@tiagocorreiaalmeida you're also creating nine different grid copies in one function call, (one when looking at each cell). This seems... excessive... though I'm not entirely sure what you're trying to do
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 13:52
it probably has tons of errores this function is based on a tutorial cause I had no idea how to perform this, I could easily use math,random or a couple of if statement but that would make the computer kinda "dumb" so I tried to see another solutions to improve it
anyway thanks @kumquatfelafel
CamperBot
@camperbot
Aug 08 2017 13:52
tiagocorreiaalmeida sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 581 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 08 2017 13:54
I think it's great to try and figure it out.
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 13:57
found out about lodash thanks to it didnt knew something like this existed :D
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 14:07
@kumquatfelafel anyawy if you ahve time to help me trought this 1 would be great :D
EpicTriffid
@EpicTriffid
Aug 08 2017 14:07
Yello all
So I'm working through the Pig Latin exercise on FCC and I've hit a snag. I can get the words beginning with vowels to work, and the suffix "way" is appearing on the end, but if I try to address the consonants, I get a series of "aywayayayay" appearing on the ends of words. I'm thinking it might be something to do with the placement of my return statement, or that the code might be running through the full vowel array, but I dont know
function translatePigLatin(str) {
  var vowel = ["a","e","i","o","u"];
  var arr = str.split("");
  for (var x = 0; x < vowel.length; x++) {
    if (arr[0] === vowel[x]) {
      arr.push("way");
    }
    else {
      arr.push("ay");
    }
  }    
  return arr.join("");
}

translatePigLatin("eight");
Stephen James
@sjames1958gm
Aug 08 2017 14:29
@EpicTriffid Use vowel.indexOf() not a for loop to test for vowels. Your else will get hit at least 4 times and for consontants 5 times
EpicTriffid
@EpicTriffid
Aug 08 2017 14:30
@sjames1958gm Thankyou! Why would indexOf work better?
CamperBot
@camperbot
Aug 08 2017 14:30
epictriffid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8272 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 08 2017 14:30
@EpicTriffid You don't have to do a loop you can check in one statement.
if (vowel.indexOf(arr[0]) == -1) then consonant
EpicTriffid
@EpicTriffid
Aug 08 2017 14:32
@sjames1958gm That's perfect! If I was going to use the for loop, is there any way to stop the else being hit by the other letters?
I'm assuming the else was going through the rest of the world and adding "way" or "ay" for each letter?
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:33
@sjames1958gm Hello
EpicTriffid
@EpicTriffid
Aug 08 2017 14:33
Just trying to make sure I'm understanding my mistakes
Stephen James
@sjames1958gm
Aug 08 2017 14:33
@EpicTriffid You'd have to wait to the end of the loop to "know" if it wasn't a vowel
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:33
Im relatively new to javascript and react
Stephen James
@sjames1958gm
Aug 08 2017 14:33
@abhinav-thinktank :wave:
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:33
ive heard of workflow automation tools like grunt and gulp
should i start learning and using them ?
never used one before..
Cody Seibert
@codyseibert
Aug 08 2017 14:35
@abhinav-thinktank it would be good to at least gloss over one of them (add webpack to that list)
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:35
@codyseibert ok!
im asking this because i was reading up on page performance optimization
which had a lot of techniques.
but grunt/gulp was mentioned many times and their plugins
EpicTriffid
@EpicTriffid
Aug 08 2017 14:36
@sjames1958gm right, so indexOf is going through the vowel array, and saying "if any of the elements are in the string are not returned (-1), do x"?
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:36
examples : minifying js/ css
Cody Seibert
@codyseibert
Aug 08 2017 14:37
yeah, almost every project will have one of those task runners to help run scripts over your code / build your project
Stephen James
@sjames1958gm
Aug 08 2017 14:37
webpack is certainly the front runner lately.
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:37
is it a workflow automation tool too?
Stephen James
@sjames1958gm
Aug 08 2017 14:38
hmm, good question, not sure
Cody Seibert
@codyseibert
Aug 08 2017 14:38
oh, there is also Browserify lol
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:39
aah..
what should i go for
Cody Seibert
@codyseibert
Aug 08 2017 14:39
I feel like gulp & grunt are more of generic task runners, but webpack & Browserify are specifically for packaging front end apps
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:39
ok.
Cody Seibert
@codyseibert
Aug 08 2017 14:39
I'd say learn a bit about webpack, and learn a bit about gulp
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:40
ok thanks for the input @codyseibert @sjames1958gm !
CamperBot
@camperbot
Aug 08 2017 14:40
abhinav-thinktank sends brownie points to @codyseibert and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 90 | @codyseibert |http://www.freecodecamp.com/codyseibert
:star2: 8273 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Cody Seibert
@codyseibert
Aug 08 2017 14:40
if you learn gulp, you'll notice grunt is very similar
Abhinav Mishra
@abhinav-m
Aug 08 2017 14:40
yeah, i was reading up on them and noticed that
i guess ill install and play around with them to see what they offer
soulproprietor
@soulproprietor
Aug 08 2017 14:41
super noob question: I'm doing the local weather app challenge, and a lot of the documentation I see is in vanilla javascript, but i already stared using jquery event handlers
for example, on w3 there is this code for how to get geolocation:
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
Try it Yourself »
would I need to "convert" to jquery? should I? or should I leave it as is
Cody Seibert
@codyseibert
Aug 08 2017 14:42
you wouldn't "need" to
soulproprietor
@soulproprietor
Aug 08 2017 14:43
should I?
Cody Seibert
@codyseibert
Aug 08 2017 14:43
I probably would to keep it consistent
soulproprietor
@soulproprietor
Aug 08 2017 14:44
so generally, people use one or the other?
Cody Seibert
@codyseibert
Aug 08 2017 14:44
not much changes with it though right?
EpicTriffid
@EpicTriffid
Aug 08 2017 14:44
When using substring, can you remove the elements and move them to the end of the word?
Cody Seibert
@codyseibert
Aug 08 2017 14:45
var x = $('demo');
function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else {
    x.html("Geolocation is not supported by this browser.");
  }
}
function showPosition(position) {
  x.html("Latitude: " + position.coords.latitude +
  "<br>Longitude: " + position.coords.longitude);
}
I think that's all that changes ^
@soulproprietor yeah, I mean if you bring jQuery into your project, I would think you are using it to help manipulate the dom; therefore, why use plain javascript if you already have jQuery
soulproprietor
@soulproprietor
Aug 08 2017 14:45
the way you call the functions or insert the HTML wouldnt change?
Cody Seibert
@codyseibert
Aug 08 2017 14:46
the way you insert html changes: notice x.innerHTML = changed to x.html()
no, your functions could stay the same probably
Stephen James
@sjames1958gm
Aug 08 2017 14:49
@EpicTriffid You can. e.g. move one letter to end str = str.slice(1) + str.slice(0, 1);
soulproprietor
@soulproprietor
Aug 08 2017 14:49
@codyseibert I guess because sometimes I find exerpts like the one above, and I dont know how to "convert" it, and would like to just copy and paste sometimes
Cody Seibert
@codyseibert
Aug 08 2017 14:51
basically if you see a "document.querySelector", "document.querySelectorAll", "document. getElementById", etc, you can use jQuery instead to grab the dom element
then use jQuery to manipulate that dom element
soulproprietor
@soulproprietor
Aug 08 2017 14:52
ok cool, that gives me enough to keep going. thank you
EpicTriffid
@EpicTriffid
Aug 08 2017 14:52
@sjames1958gm Ohhh, using slice. I'm intrigued why they would have listed substring as an option
Stephen James
@sjames1958gm
Aug 08 2017 14:52
@EpicTriffid They both work about the same, I remember the parameters to slice better
soulproprietor
@soulproprietor
Aug 08 2017 14:53
@codyseibert another question
EpicTriffid
@EpicTriffid
Aug 08 2017 14:53
@sjames1958gm Kewl
soulproprietor
@soulproprietor
Aug 08 2017 14:53
in this same code... how can you link it to the html if you dont use the onclick method?
Stephen James
@sjames1958gm
Aug 08 2017 14:53
@EpicTriffid :) you kids and your lingo
soulproprietor
@soulproprietor
Aug 08 2017 14:54
in html you can youse the onclick="" attribute
EpicTriffid
@EpicTriffid
Aug 08 2017 14:54
@sjames1958gm Sadly, I'm not a kid :P
kumquatfelafel
@kumquatfelafel
Aug 08 2017 14:54
And I'm not a lingo. :o
soulproprietor
@soulproprietor
Aug 08 2017 14:54
but using jquery I do it right in the script i think, right?
teevik
@teevik
Aug 08 2017 14:55
You can do it with or without jquery
Stephen James
@sjames1958gm
Aug 08 2017 14:56
@kumquatfelafel You are all about the lingo
teevik
@teevik
Aug 08 2017 14:56

If it's jquery, it's just $elem.click(callback); or $elem.on("click", callback);

With dom api (No jquery), it's elem.addEventListener("click", callback)

Stephen James
@sjames1958gm
Aug 08 2017 14:57
@kumquatfelafel You mustachioed rodent :)
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 15:01
@codyseibert
hey
Keith
@7KAG7
Aug 08 2017 15:01
$(document).ready(function(){
  var long;
  var lat;
  var ftemp;
  var ctemp;
  var ktemp;
  var summary;

  //create api for specific location  
  var api = "https://fcc-weather-api.glitch.me/api/current?lat=42&lon=-71";

  $.getJSON(api, function(data){
    //JSON call for api 
    var weatherType = data.weather[0].description;
    var temp = data.main.temp;
    var windSpeed = data.ein.speed;
    var name = data.name;
    var summary = data.name;

        ftemp= (ktemp)*(9/5)-459.67;
        ctemp= ktemp-273;

      console.log(city);
    $("#city").html(city);
        $("#weatherType").html(weatherType);
        $("#summary").html(summary);

  });

  });
need help please
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 15:01
how are you? was looking into your tutorial
gonna need a little help from you if its possible
Keith
@7KAG7
Aug 08 2017 15:02
this is my JS and this is my HTML
<ul>
  <li id="name"></li>
  <li id="temp"></li>
  <li id="weatherType"></li>
  <li id="summary"></li>
  <li></li>
  <li></li>
</ul>
all i see is the bullets but nothing populates
teevik
@teevik
Aug 08 2017 15:03
Any errors in console?
Keith
@7KAG7
Aug 08 2017 15:03
nope
Stephen James
@sjames1958gm
Aug 08 2017 15:04
nvm
@dudeguykid Do you see the request/response in the network tab of devtools?
Keith
@7KAG7
Aug 08 2017 15:05
Uncaught TypeError: Cannot read property 'speed' of undefined
Uncaught TypeError: Cannot read property 'speed' of undefined
at Object.success (pen.js:16)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
Stephen James
@sjames1958gm
Aug 08 2017 15:05
@dudeguykid typo? data.ein.speed -> data.wind.speed?
Keith
@7KAG7
Aug 08 2017 15:05
got this again when i ran the network req
Uncaught TypeError: Cannot read property 'speed' of undefined
at Object.success (pen.js:16)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 15:06
@codyseibert this is my pen https://codepen.io/tiagocorreia/pen/VzKxeb?editors=0010 my code is not getting into the line 67 that's where I push the values, another thing that looks confusing is that the loop is running more than the needed times?
Keith
@7KAG7
Aug 08 2017 15:06
good catch @sjames1958gm thanks
CamperBot
@camperbot
Aug 08 2017 15:06
dudeguykid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8274 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 15:06
if you can have a look since Im trying to follow your idea
Keith
@7KAG7
Aug 08 2017 15:09
anyone else have any ideas
could it have something to do with being on a work network maybe?
Blauelf
@Blauelf
Aug 08 2017 15:22
@dudeguykid Maybe data.ein does not exist in the returned data?
Keith
@7KAG7
Aug 08 2017 15:22
thanks @Blauelf
CamperBot
@camperbot
Aug 08 2017 15:22
dudeguykid sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4557 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Aug 08 2017 15:23
@dudeguykid That's only what @sjames1958gm wrote. :point_up: 8. August 2017 17:05
Keith
@7KAG7
Aug 08 2017 15:24
no i know
i figured i'd give you some brownie points anyways
i am just going to break $hit for a while
and go from there
Cody Seibert
@codyseibert
Aug 08 2017 15:28
@tiagocorreiaalmeida give me a sec
Walther Cantu
@walthercantu
Aug 08 2017 15:32
Hi all, kinda stuck in the twitch.tv project right now. I have two questions 1. How do you go around the JS Hint that tells you to not have a function inside a loop? What I'm doing right now is setting an array with the channel names and going through each of them and make an ajax call to see if they have streams going on. Which leads me to 2. How do you go about nesting ajax calls if a channel isn't streaming and you need to make an additional call to get the data from that one? Any pointers will be greatly appreciated. Here's the link to my pen: https://codepen.io/walthercantu/pen/wqJaxb/
Stephen James
@sjames1958gm
Aug 08 2017 15:33
@tiagocorreiaalmeida Dude, your gameOver function should be using the board copy, it is using the global.
@walthercantu wrap your ajax in a function and call that function from the loop
  for (var i = 0; i < users.length; i++) {
    dothestuff(users[i]);
  }

  function dothestuff(user) {
Walther Cantu
@walthercantu
Aug 08 2017 15:39
@sjames1958gm cool, cool, cool. Thanks man.
CamperBot
@camperbot
Aug 08 2017 15:39
walthercantu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8275 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 08 2017 15:39
@walthercantu :+1:
Cody Seibert
@codyseibert
Aug 08 2017 15:41
@tiagocorreiaalmeida alright, so first of all, in your gameOver function, it should take in a parameter called entrys; second, anywhere you call gameOver, you need to pass it the grid
so in minmax, you need to call gameOver(newGrid)
anywhere else, gameOver(entrys)
the reason this is a bug is because your gameOver state keeps on checking the initial grid for if the game is over
I think you have another bug somewhere, but I don't have the time to debug atm
Nathan
@clarken1996
Aug 08 2017 15:47
hey can someone tell me why /[\W]/g doesnt' find underlines?_
Jason Luboff
@JLuboff
Aug 08 2017 15:50
@clarken1996 Becuase \W matches any non-word character except underscore
Nathan
@clarken1996
Aug 08 2017 15:51
@JLuboff thanks
CamperBot
@camperbot
Aug 08 2017 15:51
clarken1996 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2136 | @jluboff |http://www.freecodecamp.com/jluboff
Thayyeb salim
@Thayyebsalim
Aug 08 2017 15:51
Guys I'm having trouble with the twitch API
Can I get some help please
https://codepen.io/Thayyeb_Itachi/pen/rzxKPg
The part in the second ajax call is what I want to try
$.ajax({
      url: streamUrl,
      type: "GET",
      dataType: "json",
      success: function(present) {
        if(status.stream!=null){
          $("#"+users[i]).append("display this ");
        }
      }
    });
Nothing is happening
Jason Luboff
@JLuboff
Aug 08 2017 15:55
@clarken1996 If you want to include _ you can either use a character set or the regex OR
/[\W_]/g //Character set
/\W|_/g // Using | OR
soulproprietor
@soulproprietor
Aug 08 2017 15:58
hey guys, another jquery question, can I go back and forth between jquery and javascript seamlessly? for example, I started a $elem.click(function(){ stuff here })', would regular javascript work inside this jquery function? vice versa, if i started a javascript function, can I put a jquery function inside?
Jason Luboff
@JLuboff
Aug 08 2017 15:59
@soulproprietor Yes, should be fine, jQuery is just a library of vanilla js
@Thayyebsalim You have status.stream!=null but shouldn't you be looking inside the returned data present?
Thayyeb salim
@Thayyebsalim
Aug 08 2017 16:00
well i tried that and nothing happened
now I just want something to get appended @JLuboff
replacing it is easy as you know
codeolas
@codeolas
Aug 08 2017 16:50

Hi all,
Why is

6505552368

not a US phone number? it is 10 characters long, what is different? ... working on the us telephone numbers challenge..

5555555555 is apparently a valid number
Stephen James
@sjames1958gm
Aug 08 2017 17:03
@codeolas from the challenge the whole string is "(6505552368)" including the ()
I think the challenge is to make sure you don't only check opening (
Moisés Man
@moigithub
Aug 08 2017 17:04
and.. should be only around first 3 digits
codeolas
@codeolas
Aug 08 2017 17:09
@sjames1958gm That's it, I missed the parenthesis. :smile: :+1:
luccifer00
@luccifer00
Aug 08 2017 17:18
https://codepen.io/luccifer00/pen/NgzmxV?editors=0010
hi there! someone can help me with my weather app??
i am not sure on how to change the background if time is clear, cloudy or raining....
also I am not able to figure out how to set "my location" with the google location API.....
a7n007
@a7n007
Aug 08 2017 17:24

@luccifer00 ```
if(ftemp<=40)
{

$('.image').css('background-image','url("http://az616578.vo.msecnd.net/files/2015/12/04/635848557150633136-120303261_winter.jpg")');}
else if((ftemp<=90&&ftemp>40))
{ $(".image").css('color','white');
$('.image').css('background-image','url("http://alliswall.com/file/1718/1920x1200/16:9/cloudy-weather-2.jpg")');}

```

@luccifer00 i did this in js to control the css element you can do some thing similar too
Jefferson
@jeffersonnnn
Aug 08 2017 17:25
hi guys, i am looking for a way to split my string into two different arrays with the intent of comparing them. This is from the mutations bonfire
Jason Luboff
@JLuboff
Aug 08 2017 17:26
@jeffersonnnn There only ever two strings in the array. You can just access them with arr[0] and arr[1]
Jefferson
@jeffersonnnn
Aug 08 2017 17:28
@JLuboff i assumed that as the are, they are cojoined as a string
Jason Luboff
@JLuboff
Aug 08 2017 17:28
No...its an array with two strings inside
Jefferson
@jeffersonnnn
Aug 08 2017 17:28
@JLuboff so i can just access them like that?
Jason Luboff
@JLuboff
Aug 08 2017 17:28
Yes
luccifer00
@luccifer00
Aug 08 2017 17:29
@a7n007 that is a good way, using the temperature.... i was thinking about using the info extracted from the api..... so when its clear , show a clear sunny day, if it is cloudy.... etc, but i have to agroup them, becouse icons have more that one atribute
icons.set("clear-day", Skycons.CLEAR_DAY)
icons.set("clear-night", Skycons.CLEAR_NIGHT)
icons.set("partly-cloudy-day", Skycons.PARTLY_CLOUDY_DAY)
icons.set("partly-cloudy-night", Skycons.PARTLY_CLOUDY_NIGHT)
icons.set("cloudy", Skycons.CLOUDY)
icons.set("rain", Skycons.RAIN)
icons.set("sleet", Skycons.SLEET)
icons.set("snow", Skycons.SNOW)
icons.set("wind", Skycons.WIND)
icons.set("fog", Skycons.FOG)

@a7n007 i would like to use that info... and when it is
clear_Day or Clear_night show clear background... when it is
partly_cloudy_day or night or cloudy show cloduy background, when it is
rain, sleet, snow, wind, or fog.... show a raining city photo as background.....

can i do that?

Jefferson
@jeffersonnnn
Aug 08 2017 17:34
@JLuboff thanks!
CamperBot
@camperbot
Aug 08 2017 17:34
jeffersonnnn sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2137 | @jluboff |http://www.freecodecamp.com/jluboff
a7n007
@a7n007
Aug 08 2017 17:50
@luccifer00 yes you can use the prepend method which allows you target specific tags ...... so you can target image tag and set the source equal to the information you get from the api.
John
@nekfhpm
Aug 08 2017 18:07
function findLongestWord(str) {

 var arr = str.split(" ");
 var big;

 for(var i=0; i<arr.length-1; i++)
 {
      if(arr[i]> arr[i+1])
          big=arr[i];

 }

  return big.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
When I retrurn big it's said it's undefined !
any help thanks
Moisés Man
@moigithub
Aug 08 2017 18:10
it returns 4 for me
"lazy">"dog"
true
soo big = "lazy"
"lazy".length :point_left: 4
John
@nekfhpm
Aug 08 2017 18:12
oh alright
Moisés Man
@moigithub
Aug 08 2017 18:12
but should be 6.. cuz "jumped" is the largest word
John
@nekfhpm
Aug 08 2017 18:57
@moigithub Solved it, thank you for your help
CamperBot
@camperbot
Aug 08 2017 18:57
nekfhpm sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3569 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph
@Big-jo
Aug 08 2017 19:24
is it possible to change the src attribute of a script from another script
Moisés Man
@moigithub
Aug 08 2017 19:27
probably...
i know u can dynamically add scripts, so editing should be the same as modifing any other tag
Joseph
@Big-jo
Aug 08 2017 19:29
please can you give an example
<script src="https://maps.googleapis.com/maps/api/geocode/json?address=State&key=AIzaSyBCyqeNvQ2ykQl524BcIWr_XAJwApEyWZU "></script>
because im trying to change the value of address from another script
Moisés Man
@moigithub
Aug 08 2017 19:33
script = document.createElement('script');
script.onload = function() {
  alert("today is "+moment().format());
};
script.src = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
create a script on the fly.. set a src attribute..
and append to the "current" document
u can copy/paste that code on ur console devtools and it will show a date using moment.js library
Joseph
@Big-jo
Aug 08 2017 19:36
i mean the value of address changes according to the user and i need to use an api to request for a new address every time , and obviously i cant change the address value for every user that wants to use the service
Ruchika Sharma
@ruchika90
Aug 08 2017 19:37
@Manish-Giri ty it worked
CamperBot
@camperbot
Aug 08 2017 19:37
ruchika90 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6386 | @manish-giri |http://www.freecodecamp.com/manish-giri
Moisés Man
@moigithub
Aug 08 2017 19:38
why not using ajax request ? @Big-jo
Joseph
@Big-jo
Aug 08 2017 19:39
i dont know how to
but i'm looking it up
Moisés Man
@moigithub
Aug 08 2017 19:40
did u finish quotes exercise ? used api or hardcoded array?
Joseph
@Big-jo
Aug 08 2017 19:42
Nope i didnt, :cry:
Moisés Man
@moigithub
Aug 08 2017 19:47
searching on youtube there are many tuts about jquery getJSON
Joseph
@Big-jo
Aug 08 2017 19:47
@moigithub thanks
CamperBot
@camperbot
Aug 08 2017 19:47
big-jo sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3570 | @moigithub |http://www.freecodecamp.com/moigithub
Pethaf
@Pethaf
Aug 08 2017 19:49
Oh, I'm #4014 on the freecodecamp leaderboard.
I wonder if that is a good score.
Stephen James
@sjames1958gm
Aug 08 2017 19:52
@Pethaf You're on the board that means you are making progress.
Pethaf
@Pethaf
Aug 08 2017 19:53
I haven't really done much since late june.
Have to finish my thesis and a school project.
Joseph
@Big-jo
Aug 08 2017 20:00
  var head= document.getElementsByTagName('head')[0]
my JS is really rusty, what does this mean please
Diego Mayer
@Chrono79
Aug 08 2017 20:01
@Big-jo getElementsByTagName returns an array, you're getting the first of them using those brackets and 0
Joseph
@Big-jo
Aug 08 2017 20:04
@Chrono79 thanks
CamperBot
@camperbot
Aug 08 2017 20:04
big-jo sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4509 | @chrono79 |http://www.freecodecamp.com/chrono79
Pethaf
@Pethaf
Aug 08 2017 20:05
@Big-jo You probably want to use document.querySelectorAll instead.
Joseph
@Big-jo
Aug 08 2017 20:10
@Pethaf yh thanks, i didnt think of that
CamperBot
@camperbot
Aug 08 2017 20:10
big-jo sends brownie points to @pethaf :sparkles: :thumbsup: :sparkles:
:cookie: 382 | @pethaf |http://www.freecodecamp.com/pethaf
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 20:41
thanks @codyseibert just came back, just did the changes you pointed out, thanks for looking into it and aswell for a great tutorial, still got something wrong like you said will figure it out :)
CamperBot
@camperbot
Aug 08 2017 20:41
tiagocorreiaalmeida sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
:cookie: 91 | @codyseibert |http://www.freecodecamp.com/codyseibert
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 20:41
thanks aswell @sjames1958gm
CamperBot
@camperbot
Aug 08 2017 20:41
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8276 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Mark Kubik
@KUBIX90
Aug 08 2017 20:45
Hi All,
I'm having trouble with some code below that is returning undefined
Brad
@bradtaniguchi
Aug 08 2017 20:46
@KUBIX90 go ahead
Mark Kubik
@KUBIX90
Aug 08 2017 20:46
 $$LaTeX code$$

function likes(names) {
var names = [];
for (var i = 0; i < names.length; i++) {
if (names == false) {
console.log("no one likes this");
} else if (names === 0) {
console.log(names[0] + " likes this");
} else if (names > 1) {
console.log(names[0] + "," + names[1] + " and" + names[2] + " like this");
} else if (names > 2) {
console.log(names[0] + "," + names[1] + " and" + names[i++] + "others like this");
}
}
}

var noOne = likes();
var people = likes("Peter", "Dave", "Roy");

console.log(noOne);
console.log(people);

Diego Mayer
@Chrono79
Aug 08 2017 20:47
@KUBIX90 your function doesn't return a value, try replacing the console.log with return, and don't overwrite the parameter with an empty array (well, you're actually creating a local var with the same name)
Brad
@bradtaniguchi
Aug 08 2017 20:47
be sure to use the backticks to format your code so we can read it ```
Ginger
@GingerChew
Aug 08 2017 20:48
I need some help with applying this java script function to an input element. I wanna try and have it so each time a button is pressed it will do an api search of the wiki api. I.E. searches for b,be, and then bee, if I start typing the word bee. https://codepen.io/WatchConnorCode/pen/JybGVJ?editors=1000 I got the search to work prior to messing with this new idea and maybe its just convoluted (not helpful/useful) but I'd like to try and solve it if possible.
Guderian Raborg
@hypercuber
Aug 08 2017 20:49
I am trying to practice setInterval and I want to make a chess board where every second the white tile turn black and visa versa.
https://codepen.io/hypercuber/pen/zdZgwy?editors=1010
Mark Kubik
@KUBIX90
Aug 08 2017 20:51
Apologies, i'll try and make it more readable next time
I've replaced the console.log with return, but still getting undefined :(
Christopher McCormack
@cmccormack
Aug 08 2017 21:03
@hypercuber this worked for me:
let counter = 0;

function draw() {
  for (let i = 0; i < 8; i++) {
    for (let j = 0; j < 8; j++) {
      c.fillStyle = (i + j) % 2 === counter ? 'white' : 'black';
      c.fillRect(i * 50, j * 50, 50, 50);

    }
  }
  counter = counter===0?1:0;
}
Diego Mayer
@Chrono79
Aug 08 2017 21:04
@KUBIX90 did you remove the var names = []; line? And why are you comparing names (an array) against a number or false?
var names = [];
for (var i = 0; i < names.length; i++) { // names.length is 0 so your loop won't ever run and you have no code outside it
Cody Seibert
@codyseibert
Aug 08 2017 21:05
@tiagocorreiaalmeida :thumbsup:
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:07
@codyseibert do you have some minutes to help me find out why my code doesnt run the values.push ?if you are busy maybe another time will keep on my own
Cody Seibert
@codyseibert
Aug 08 2017 21:09
link me your updated code please
Mark Kubik
@KUBIX90
Aug 08 2017 21:10
@Chrono79 I created the var names = []; as im looking to fill it with names that i can call , like I've tried in the variables that I have set up at the bottom
Cody Seibert
@codyseibert
Aug 08 2017 21:10
@tiagocorreiaalmeida ^
Diego Mayer
@Chrono79
Aug 08 2017 21:10
@KUBIX90 that var hides the parameter
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:10
https://codepen.io/tiagocorreia/pen/VzKxeb I update the gameOver function accepting a parameter like you told me to then called the gameOver function everytime with the array entrys, only on the minmaxI use the GridCopy
just writed some console logs to see where the codes jumps out
Joseph
@Big-jo
Aug 08 2017 21:12
Hi guys i'm getting this error from my API call
kumquatfelafel
@kumquatfelafel
Aug 08 2017 21:12
@KUBIX90 initializing a variable with the same name as your parameter when you need said parameter is a no no. If you can afford to never use a parameter, then you don't need to include it.
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:12
            var value = minmax(gridCopy,depth + 1, (player === userMark) ? computerMark : userMark)
Joseph
@Big-jo
Aug 08 2017 21:12
image.png I keep getting this error from my api call
Diego Mayer
@Chrono79
Aug 08 2017 21:12
@KUBIX90 you should call your function like this passing an array var people = likes(["Peter", "Dave", "Roy"]); and names would be an array
Another way is calling it like this: var people = likes("Peter", "Dave", "Roy"); and using arguments object to get those values
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:12
is there anything wrong?
feel like the problem is there
and sorry @codyseibert to bother you once again
Diego Mayer
@Chrono79
Aug 08 2017 21:17
@Big-jo make a codepen
Joseph
@Big-jo
Aug 08 2017 21:17
@Chrono79 i cant , it's some long stuff
basicall i just want to lnow if the JSON response is google's fault , i mean the syntax error
Diego Mayer
@Chrono79
Aug 08 2017 21:18
@Big-jo make it short then, only the part that fails
Mark Kubik
@KUBIX90
Aug 08 2017 21:20

@Chrono79

function likes(names) {

    for (var i = 0; i < names.length; i++) {
        if (names == false) {
             return("no one likes this");
        } else if (names === 0) {
             return(names[0] + " likes this");
        } else if (names > 1) {
            return(names[0] + "," + names[1] + " and" + names[2] + " like this");
        } else if (names > 2) {
             return(names[0] + "," + names[1] + " and" + names[i++] + "others like this");
        }
    }
}

var people = likes(["Peter", "Dave", "Roy"]);

console.log(people);

This is where i am at currently, I think im calling the function the way you suggest, but still getting undefined

Tam Nguyen
@tam-nguyen
Aug 08 2017 21:20
could anyone help me with this
Diego Mayer
@Chrono79
Aug 08 2017 21:22
@KUBIX90 that's because you're still comparing an array against false or a number
you should use names.length in each if condition
You don't need the loop
note that names.length > 1 if you have more than 3 names is true, so your last return won't ever run
Mark Kubik
@KUBIX90
Aug 08 2017 21:27
@Chrono79 Ive got somewhere! I've changed the names to i in the if statement which seems to have at least given me back the string that "Peter likes this"
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:27
@codyseibert just tried to console.log right after the var value it doesnt console log the variable
something wrong there can't figure out what :D
Mark Kubik
@KUBIX90
Aug 08 2017 21:29
I used false as I want the console to return that "no one likes this" if i call the function with no values in the array, is that not correct?
Diego Mayer
@Chrono79
Aug 08 2017 21:29
@KUBIX90 why are you using a loop? Note that return exits the loop and the function
kumquatfelafel
@kumquatfelafel
Aug 08 2017 21:29
Diego Mayer
@Chrono79
Aug 08 2017 21:29
No, you should test the array length if you always pass an array
if you can call likes like this likes(); you should test for undefined, because you can't test undefined.length in the loop
Mark Kubik
@KUBIX90
Aug 08 2017 21:31
@Chrono79 I thought by using a loop that it would be more flexible in allowing me to add as many "people" as i like, without writing so much code
Diego Mayer
@Chrono79
Aug 08 2017 21:32
@KUBIX90 use the loop outside your function, when you call the function instead
Mark Kubik
@KUBIX90
Aug 08 2017 21:33
@kumquatfelafel Thansk for this, I'll have a read through
Diego Mayer
@Chrono79
Aug 08 2017 21:34
var  people = ["Peter", "Dave", "Roy", "James"];
for (var j=0; j<people.length; j++) {
  console.log(likes(people.slice(0,j)));
}
Cody Seibert
@codyseibert
Aug 08 2017 21:34
@tiagocorreiaalmeida inside gameOver, you need to make sure you replace any an all "entrys" to "array"
you only fixed the first if statement
kumquatfelafel
@kumquatfelafel
Aug 08 2017 21:35

You add, at most, 3 people, and follow a specific format. You don't really need a loop for that.

also, if this is codewars challenge, others like this is preceded by the number of additional likes excluding the first two. Not each person name.

e.g.
suppose names is ["John", "Larry", "a", "b" , "c", "d", "e"]

That will give you John, Larry, and 5 others like this.

Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:35
@codyseibert jesus sorry you are right second mate
Cody Seibert
@codyseibert
Aug 08 2017 21:36
also
@tiagocorreiaalmeida you need to include version 4.x of lodash
I'm not sure what version lodash-fp is
there should be lodash in the codepen dropdown
Diego Mayer
@Chrono79
Aug 08 2017 21:37
@kumquatfelafel it seems it is
likes([]) // must be "no one likes this"
likes(["Peter"]) // must be "Peter likes this"
likes(["Jacob", "Alex"]) // must be "Jacob and Alex like this"
likes(["Max", "John", "Mark"]) // must be "Max, John and Mark like this"
likes(["Alex", "Jacob", "Mark", "Max"]) // must be "Alex, Jacob and 2 others like this"
Mark Kubik
@KUBIX90
Aug 08 2017 21:38
@Chrono79 @kumquatfelafel Thank you both for your help, I'll go away and give this a go. Yes, it is a codewars challenge that I've struggled with for a while so kinda a last resort to come here and look for some help
CamperBot
@camperbot
Aug 08 2017 21:38
kubix90 sends brownie points to @chrono79 and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 582 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 4510 | @chrono79 |http://www.freecodecamp.com/chrono79
Cody Seibert
@codyseibert
Aug 08 2017 21:38
@tiagocorreiaalmeida remove all the console logs from your program before you try running it or else it will probably freeze your tab
Diego Mayer
@Chrono79
Aug 08 2017 21:39
@KUBIX90 hint, you don't need a loop at all
Cody Seibert
@codyseibert
Aug 08 2017 21:39
@tiagocorreiaalmeida but if you fix those two things, it will work fine
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:39
@codyseibert yeah freezing :D trying to figure out if I writted any infinite loop but probably that xd thanks
CamperBot
@camperbot
Aug 08 2017 21:39
tiagocorreiaalmeida sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
:warning: tiagocorreiaalmeida already gave codyseibert points
luccifer00
@luccifer00
Aug 08 2017 21:39
function showCel(celCel) {
       $("#thirdCell").html(celCel+ celsGrade + "<br>" + fara.fontsize(3))
    }
I am trying to do onmouseove, to change a value from an API in faranheit to Celsius..... but nothing happens... what i am missing there?? i need a document.getelementbyid??
Diego Mayer
@Chrono79
Aug 08 2017 21:40
@luccifer00 how are you calling that function? What is celCel?
luccifer00
@luccifer00
Aug 08 2017 21:41
the mouseover is showCel (celCel) i also try wit () empty
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:41
@codyseibert worked thanks for your time
CamperBot
@camperbot
Aug 08 2017 21:41
tiagocorreiaalmeida sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
:warning: tiagocorreiaalmeida already gave codyseibert points
Diego Mayer
@Chrono79
Aug 08 2017 21:41
codepen link
CamperBot
@camperbot
Aug 08 2017 21:41
luccifer00 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4511 | @chrono79 |http://www.freecodecamp.com/chrono79
luccifer00
@luccifer00
Aug 08 2017 21:42
sorry if it is a dirty code... i am learning :D @Chrono79
Gersho
@Gersho
Aug 08 2017 21:42
shouldn't it show your location instead of "Your Location" at the top ?
luccifer00
@luccifer00
Aug 08 2017 21:45
@Gersho thats an other fight ...... i cant able to understand de google location api.... i have to key, i set the variables, but i can not figure out how to change that....
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:46
doenst the api you are using for weather doesnt return location aswell?
Gersho
@Gersho
Aug 08 2017 21:47
probably, if you could show us the object returned
luccifer00
@luccifer00
Aug 08 2017 21:48

@Gersho i just change the

<h1 id= "locate" class="header text-center">Your Location</h1>

but i dindt change nothing on that.... not return province or state, or nothing... always apear my title "your location"

Gersho
@Gersho
Aug 08 2017 21:48
btw you talked about mouse over, but shouldn't you aim for mouse click instead ? if i want to see temp in C, i want it to stay that way, not return to F display as soon as my mouse leaves
luccifer00
@luccifer00
Aug 08 2017 21:50
@tiagocorreiaalmeida i also belive that, but i dindt find the way ..... i readed that i need the location as necesary element for an other kind of request.... time zone i belive....
@Gersho you are right, have more sense to to like that.... i just would like to prove with moseover, becouse i never used ..... and once i do it , i thing it is easy to make a button or mouse click...
Paul
@candlefish
Aug 08 2017 21:52
@luccifer00 It looks like you have defined your showCel function within the AJAX call. I'd recommend moving it to the document.ready scope.
Gersho
@Gersho
Aug 08 2017 21:54
for your location issue you might want to try goolging "reverse geocoding"
luccifer00
@luccifer00
Aug 08 2017 21:54
@tiagocorreiaalmeida https://darksky.net/dev/docs/response timezone is required... but i dont know how to get it , i read to use google location api
Gersho
@Gersho
Aug 08 2017 21:54
i haven't done the weather api challenge yet so i don't know much more about it sorry
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 21:55
@luccifer00 not sure about that api I used another one if you wanna give it a look
gotta go for today see you tomorrow and gl mate
Gersho
@Gersho
Aug 08 2017 21:55
@luccifer00 Date.prototype.getTimezoneOffset()
Diego Mayer
@Chrono79
Aug 08 2017 21:55
@luccifer00 click the arrow down on js panel, then click Analyze JS, try clearing all the red marks
luccifer00
@luccifer00
Aug 08 2017 21:56
thanks @Gersho . @candlefish i was thinking about that.... really, but i am using everithing inside the Ajax.... lol, maybe it is a very begginier way to start! sorry...
CamperBot
@camperbot
Aug 08 2017 21:56
luccifer00 sends brownie points to @gersho and @candlefish :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @candlefish |http://www.freecodecamp.com/candlefish
:cookie: 312 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Aug 08 2017 21:56
@tiagocorreiaalmeida why does it ask to allow notifications ?
@luccifer00 haha, i do random stuff too, i haven't finished weather API but played a lot on the Simon challenge
luccifer00
@luccifer00
Aug 08 2017 21:59
@Gersho lol that is my next challenge i think.....
Gersho
@Gersho
Aug 08 2017 22:00
https://codepen.io/Gersho/pen/weVQjr almost pulled my hair out on the css (i hate css)
luccifer00
@luccifer00
Aug 08 2017 22:02
@tiagocorreiaalmeida that is what i would like to créate.... i dont know why i make more complicate something simple... you did it so simple but so efficent... i will study thanks all guys
CamperBot
@camperbot
Aug 08 2017 22:02
luccifer00 sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Gersho
@Gersho
Aug 08 2017 22:02
@luccifer00 first make it work, then make it pretty
luccifer00
@luccifer00
Aug 08 2017 22:02
nice advice
Gersho
@Gersho
Aug 08 2017 22:03
in a work setting it might not even be the same person taking care of those 2 parts of the project
Paul
@candlefish
Aug 08 2017 22:04
@luccifer00 When you finish clearing all the red marks as @Gersho recommended, I think you should remove the onmouseover from your html and use jQuery instead, like $( "#thirdCell" ).mouseover(function() { . . . }); and just put the code you want to run on the mouseover event between the brackets.
Gersho
@Gersho
Aug 08 2017 22:07
since i said that, i suppose i should get back to making my pomodoro beautiful :| i hate css
luccifer00
@luccifer00
Aug 08 2017 22:08
oooook!! i was searching mouseover JavaScript, and all them are using the HTML , at the begining.... @candlefish perfect! i am clearing all the red marks right now! thanks
CamperBot
@camperbot
Aug 08 2017 22:08
luccifer00 sends brownie points to @candlefish :sparkles: :thumbsup: :sparkles:
:warning: luccifer00 already gave candlefish points
Gersho
@Gersho
Aug 08 2017 22:10
@luccifer00 everybody has it's preferences i guess, i'm too newb too to really have a opinion about it, but i also set up those events in the js rather than the html like so:
 $("#pomodoro-more").on("click",function(){
    pomodoroSetting += 1;
    $("#pomodoro-value").html(pomodoroSetting);
    });
wait
Tiago Correia
@tiagocorreiaalmeida
Aug 08 2017 22:31
@Gersho cause i use your location to get the time of your zone mate, and @luccifer00 dont worry I struggled alot unthil making it work and like @Gersho said first make it work and then you make the rest
weather*
Gersho
@Gersho
Aug 08 2017 22:33
lat: 16.33
long: -61.35
AST (Atlantic Standard Time)
UTC/GMT -4 hours
luccifer00
@luccifer00
Aug 08 2017 22:37
@Gersho so using Date.prototype.getTimezoneOffset() i can get return my location? i fixed the red stuff, now i am trayng to use the onmouseover function inside the JS, (i deleted from HTML as @candlefish said.... after that i fight with the location stuff, and the background change if its sunny cloudy or raining...
Gersho
@Gersho
Aug 08 2017 22:39
@luccifer00 sorry i have no idea, i looked "timezone" into the doc and the description seemed like it could help get you a timezone
the background shouldn't be a problem, do a switch/case that will change the background depending on the weather
dyon3334
@dyon3334
Aug 08 2017 22:42

can someone tell me why this not adding numer in the array ?```
function factorialize() {
var arr=[];
for (i=1;i<10;i++){
arr.push(i);
if (i <= 10){
return arr;}
}

}

factorialize();```

Gersho
@Gersho
Aug 08 2017 22:44
because
if (i <= 10){
return arr;}
will force it to return on it's first itterence
Paul
@candlefish
Aug 08 2017 22:44
@luccifer00 I'm still looking at your code. I'll get back to you soon
Gersho
@Gersho
Aug 08 2017 22:44
i'm guessing it returns 1 only ?
dyon3334
@dyon3334
Aug 08 2017 22:45
@Gersho yes it does
luccifer00
@luccifer00
Aug 08 2017 22:45
var celsius ="Show Celsius";
    var celsGrade =" ºC";
    var fara ="Return Fahrenheit";
    var faraGrade =" ºF";
    var winspeed = "Wind Speed";
$("#scondCell2").html(windspeed + "<br>" + winspeed.fontsize(3)); 
    $("#thirdCell").html(temperature+ faraGrade + "<br>" + celsius.fontsize(3)).onmouseover(function() { 
    $("#thirdCell").html(celCel+ celsGrade + "<br>" + fara.fontsize(3));
    });
maybe i am crazy, hehe, but i dont know where to put 'onmouseover' , and also, i am not sure what function i should créate.... i just want to change the number and the ºF or ºC
dyon3334
@dyon3334
Aug 08 2017 22:45
can you explain me what am i doing wrong
luccifer00
@luccifer00
Aug 08 2017 22:46
thanks in advance @candlefish (again, sorry if my code is crazy... :)
CamperBot
@camperbot
Aug 08 2017 22:46
luccifer00 sends brownie points to @candlefish :sparkles: :thumbsup: :sparkles:
:warning: luccifer00 already gave candlefish points
kumquatfelafel
@kumquatfelafel
Aug 08 2017 22:47
@dyon3334 It's adding the number, but your return statement halts for loop and function returning specified value immediately .
aRtoo
@artoodeeto
Aug 08 2017 22:47
anyone here can help me with algorithm??
luccifer00
@luccifer00
Aug 08 2017 22:47
temperature is the value from the API
Gersho
@Gersho
Aug 08 2017 22:47
@dyon3334 really depends what you're trying to do, if you just want to return a array [1,2,3...,10] simply remove the if/return block i pasted earlier, and put your return after your for i loop (outstide of it)
dyon3334
@dyon3334
Aug 08 2017 22:48
@gersho okey im gonna try
@Gersho thaks
@Gersho thanks !!
CamperBot
@camperbot
Aug 08 2017 22:48
dyon3334 sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @gersho |http://www.freecodecamp.com/gersho
kumquatfelafel
@kumquatfelafel
Aug 08 2017 22:48
e.g.
for (var i = 0; i < 10; i++) {
   return 5; // this statement is only executed once
}
dyon3334
@dyon3334
Aug 08 2017 23:04

my solution for https://www.freecodecamp.org/challenges/factorialize-a-number
``
function factorialize(num) {
var arr=[];
var y = 0;
var sum=1;
for (i=1;i<=num;i++){
y++;
arr.push(y);
}
for(i=0;i<arr.length;i++){
sum = sum * arr[i];}
return sum;

}

factorialize(10);`
```

my solution for https://www.freecodecamp.org/challenges/factorialize-a-number
function factorialize(num) {
  var arr=[];
  var y = 0;
  var sum=1;
  for (i=1;i<=num;i++){ 
    y++;
    arr.push(y);
     }
  for(i=0;i<arr.length;i++){
  sum = sum * arr[i];}
  return sum;


}

factorialize(10);`
does anyone has suggestions ?
Valentin
@valentinlybmin
Aug 08 2017 23:05

I am doing the "Everthing be true" from the front end section of the map

I am

kumquatfelafel
@kumquatfelafel
Aug 08 2017 23:05
@dyon3334 you don't need to put the numbers into an array before multiplying them.
dyon3334
@dyon3334
Aug 08 2017 23:06
@kumquatfelafel why not a array ?
can you write me you alternative
Valentin
@valentinlybmin
Aug 08 2017 23:07

I am doing this https://www.freecodecamp.org/challenges/everything-be-true

What I do not get is how I am suppouesd to check if something is NaN, when I put isNaN(); it returns true on so many things, since I cannot find a way to grab only this one truthCheck([{"single": "double"}, {"single": NaN}], "single")

this is my code


function truthCheck(collection, pre) {


  var isTruthy = true;

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

    if(typeof collection[i][pre] === 'undefined' ||
        collection[i][pre] === false ||
        collection[i][pre] === 0 ||
        collection[i][pre] ===null||
       collection[i][pre] ===""
      ){
      isTruthy = false;
    }

  }

  return isTruthy;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age");

As you can see, I have not included the isNaN function, because it messes up other tests

kumquatfelafel
@kumquatfelafel
Aug 08 2017 23:08
@dyon3334 there's no need for an array. You're doing in two for loops what you could do in one.
for (i=1;i<=num;i++){ 
   //what is value of i in first iteration? second? third? fourth? etc?
}
Gersho
@Gersho
Aug 08 2017 23:10
i wanted to check how i did it but the site apparently forgot :/ but i think i used for (i=num; i=1; i--) and justmultiplied stuff
dyon3334
@dyon3334
Aug 08 2017 23:10
@kumquatfelafel thanks im gonna fix it now