These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Aug 2017
Bradley Sands
@sandsbe
Aug 10 2017 00:00 UTC
Ok, but neither setTimeoutor setInterval are standard method/functions in JS. So...?
Jim Tryon
@jimtryon
Aug 10 2017 00:01 UTC
They are JS functions.
Jim Tryon
@jimtryon
Aug 10 2017 00:03 UTC
You seem to be looking at a different documentation
Bradley Sands
@sandsbe
Aug 10 2017 00:04 UTC
@jimtryon, you're right. I couldn't find them on http://devdocs.io/.
I was searching setInterval and nothing was popping up.
Stephen James
@sjames1958gm
Aug 10 2017 01:35 UTC
setTimeout(f, time) will call function f after time msec, setInterval(f, time) will call f every time msec (approx.)
Both return a reference to the timer that can be cancelled.
For the clock, setInterval is probably more approriate as a timer tick, at 1 second (1000 msec).
When I was debugging mine I had a variable that allowed me to speed the clock up for testing.
insouciantone
@insouciantone
Aug 10 2017 01:37 UTC
Hello all. I'm working on the weather API app and I'm having a hard time getting my code to call the API. I've been fiddling with this for about an hour.
Why isn't my javascript calling the API?
Ken Haduch
@khaduch
Aug 10 2017 01:38 UTC
@insouciantone - right now, you're getting an error that is stopping progress - Uncaught ReferenceError: jsonURL is not defined
Stephen James
@sjames1958gm
Aug 10 2017 01:38 UTC
@insouciantone You have two variables jsonUrl and jsonURL - and they don't match
Always, always, I repeat always open your devtools console and look for errors
insouciantone
@insouciantone
Aug 10 2017 01:38 UTC
derp
yeah that was it, gotta be more perceptive. Thanks @khaduch & @sjames1958gm
CamperBot
@camperbot
Aug 10 2017 01:39 UTC
insouciantone sends brownie points to @khaduch and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 3190 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 8285 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ken Haduch
@khaduch
Aug 10 2017 01:39 UTC
@insouciantone - that will fix it - you get your JSON dumped into the DOM
Stephen James
@sjames1958gm
Aug 10 2017 01:39 UTC
It is almost instinctive for me to open the console
insouciantone
@insouciantone
Aug 10 2017 01:40 UTC
I should've noticed it from the syntax highlighting alone
but I guess I was just being sloppy from working on it so long
Ken Haduch
@khaduch
Aug 10 2017 01:40 UTC
@insouciantone - yes, open the devtools console (not the CodePen console) and also you can use the "Analyze JS" in the JS panel dropdown on the right - it catches some things that can be helpful.
insouciantone
@insouciantone
Aug 10 2017 01:40 UTC
I actually do have the dev tools open but I wasn't looking at the console, silly me
welp, now to work on parsing and formatting this mess. Thanks again.
Ken Haduch
@khaduch
Aug 10 2017 01:41 UTC
@insouciantone - it just has to become an ingrained habit... as you get more exposure to it you'll get in the habit of checking.
Stephen James
@sjames1958gm
Aug 10 2017 01:45 UTC
@insouciantone :+1:
juni
@junipberry
Aug 10 2017 01:55 UTC

Hello~~
Could I get some help for my code pls.
I need to convert the formatting of a dataset from arrays to objects.
This is what I have so far:

```function transformData(array) {
let myObj= {};
let myLgth= array.length;

for (let i=0; i<myLgth; i++){
for (let j=0; j<array[i].length; j++){
myObj[i][j]=array[i][j];
}
}
return myObj;

}
```

Hello~~
Could I get some help for my code pls.
I need to convert the formatting of a dataset from arrays to objects.
This is what I have so far:
function transformData(array) {
  let myObj= {};
  let myLgth= array.length;

  for (let i=0; i<myLgth; i++){
    for (let j=0; j<array[i].length; j++){
     myObj[i][j]=array[i][j];
  }
  }
  return myObj;

}
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:04 UTC
@junipberry for future, you can edit a post by clicking the ... that appears when you hover your mouse over your comment.
@junipberry could you provide an example argument for array? Is it supposed to be a 2d array?
Addison
@addisonday
Aug 10 2017 02:14 UTC
Just got through the basic Javascript!
Pete Givens
@petegivens
Aug 10 2017 02:18 UTC
@addisonday congrats
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:18 UTC
@junipberry do you want your object to look like this https://repl.it/KEKA, e.g., or like something else?
CallMeOrange
@EgnaroDev
Aug 10 2017 02:18 UTC
lol, I was wondering what you mean by e.g.
Addison
@addisonday
Aug 10 2017 02:19 UTC
@petegivens Thank you!
CamperBot
@camperbot
Aug 10 2017 02:19 UTC
addisonday sends brownie points to @petegivens :sparkles: :thumbsup: :sparkles:
:cookie: 276 | @petegivens |http://www.freecodecamp.com/petegivens
Pete Givens
@petegivens
Aug 10 2017 02:19 UTC
i'm having some trouble using setTimeout
it calls my function but it doesn't respect the time delay, just runs the function immediately
this is what I'm using: setTimeout(alert('hey'), 5000);
am I missing something obvious?
Ginger
@GingerChew
Aug 10 2017 02:22 UTC
I think I am missing something with this array iterator, I wanna get the names from the array to be listed in the list items and for a list to be generated at the bottom of the card. https://codepen.io/WatchConnorCode/pen/QMvoje?editors=0010
Alexander Køpke
@alexanderkopke
Aug 10 2017 02:23 UTC
@petegivens not sure but try adding function to it: setTimeout(function(){ alert('hey')},5000)
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:23 UTC

for (var i; i < twitchUsers.length; i++)

i = ??

@GingerChew
Ginger
@GingerChew
Aug 10 2017 02:24 UTC
@kumquatfelafel yep, that would do it, thanks m8
CamperBot
@camperbot
Aug 10 2017 02:24 UTC
gingerchew sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 589 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:24 UTC
@GingerChew can't guarantee that's everything, but in particular stuck out. ;)
Pete Givens
@petegivens
Aug 10 2017 02:25 UTC
@alexanderkopke thank you, that works. I guess the way I was writing it the function was being invoked immediately. Need to pass setTimeout a named function without parens or a function declaration
CamperBot
@camperbot
Aug 10 2017 02:25 UTC
petegivens sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1638 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Ginger
@GingerChew
Aug 10 2017 02:25 UTC
yeah, I gotta specify some more, but thats gonna be just some html edits, the jquery always gets me
Claudio Restifo
@Marmiz
Aug 10 2017 02:25 UTC
@petegivens how you call the function alert.
Should be inside the setTimeout function argument:
setTimeout( () => {
 // your method here
}, 1500)
Pete Givens
@petegivens
Aug 10 2017 02:26 UTC
@Marmiz thank you
CamperBot
@camperbot
Aug 10 2017 02:26 UTC
petegivens sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1015 | @marmiz |http://www.freecodecamp.com/marmiz
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:33 UTC
@EgnaroDev family secret! :o
LovingVi
@LovingVi
Aug 10 2017 02:36 UTC
Hello~
I need some help about my code.
I want to get the maximum value of each array.
But it return the same number.

function largestOfFour(arr) {
for(var i = 0;i<arr.length;i++){ var max = arr[i][0]; var myArr = []; for(var n = 0;n < arr[i].length;n++){ arr[i][n] > max ? (max = arr[i][n]):max;
myArr.push(max);
max = arr[i][0];
}
}
return myArr;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);

it returned [1000000,100000,100000,100000]
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:38 UTC

@LovingVi For future: if you write your code in a code block, it makes it easier to read and allows you to do some formatting. To write it in a code block...
for one line :point_right: ` code goes here ` :point_left:
or for multiple lines :point_down:
```js
code goes here (important: keep your code on a separate line from backticks)
```
:point_up:

Also, note that ` is not the same as '
You can also edit your post if you make a mistake by clicking the … that appears when you hover your mouse over your comment

LovingVi
@LovingVi
Aug 10 2017 02:47 UTC
var code = "formatted";
CallMeOrange
@EgnaroDev
Aug 10 2017 02:48 UTC
@LovingVi
Margaret
@Margaret2
Aug 10 2017 02:48 UTC
@LovingVi because you put var myArray = [] inside your for loop so each time it creates a new array, that's why you only have the number from the last array
CallMeOrange
@EgnaroDev
Aug 10 2017 02:48 UTC
```js
code
```
to
code
LovingVi
@LovingVi
Aug 10 2017 02:48 UTC
OK
LovingVi
@LovingVi
Aug 10 2017 02:55 UTC
@EgnaroDev Sorry I'm a newcomer and don't know how to use these methods。
@Margaret2 TKS
Ginger
@GingerChew
Aug 10 2017 02:58 UTC
I'm confused about this api call? I can't figure out where the callback=? is supposed to go ```
"https://wind-bow.gomix.me/twitch-api/users?callback=?login=" + twitchUsers
CallMeOrange
@EgnaroDev
Aug 10 2017 02:59 UTC
I think ?callback=? is always at the end, not sure...
Long Nguyen
@longnt80
Aug 10 2017 02:59 UTC
@GingerChew just use this: https://wind-bow.glitch.me/twitch-api/users/freecodecamp
no need for callback
replace freecodecamp with other username
Ginger
@GingerChew
Aug 10 2017 03:00 UTC
@longnt80 okay, I was confused how that endpoint was supposed to work
@longnt80 thanks m8
CamperBot
@camperbot
Aug 10 2017 03:00 UTC
gingerchew sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 488 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Aug 10 2017 03:00 UTC
@GingerChew yeah the instruction for that project is confusing
I meant the API
Ginger
@GingerChew
Aug 10 2017 03:15 UTC
Am I supposed to hard code each json request for each listed user?
leetboy
@leetboy
Aug 10 2017 03:21 UTC
tg
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:22 UTC
What does the this mean guys??
return str.slice(0, num > 3 ? num - 3 : num) + '...';
Long Nguyen
@longnt80
Aug 10 2017 03:23 UTC
@ma5one1 you meant this part num > 3 ? num - 3 : num?
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:23 UTC
exaclty
Long Nguyen
@longnt80
Aug 10 2017 03:23 UTC
that is equivalent to:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:23 UTC
if num > 3 then it's like saying...
str.slice(0, num - 3)
otherwise,
str.slice(0, num)
Long Nguyen
@longnt80
Aug 10 2017 03:23 UTC
yeah this :point_up: August 10, 2017 10:23 AM
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:24 UTC
I'll leave more generalized explanation to @longnt80
err... :laughing:
Long Nguyen
@longnt80
Aug 10 2017 03:24 UTC
:D
I can't remember what that part is called
@ma5one1 oh yeah, Conditional (ternary) Operator
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:25 UTC
whats this :3
o yeah
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:26 UTC
ternary.
Long Nguyen
@longnt80
Aug 10 2017 03:26 UTC
I can't remember that word
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:27 UTC
got it..now i got to remember it round of brownie
:clap:
@longnt80 thank you
CamperBot
@camperbot
Aug 10 2017 03:28 UTC
ma5one1 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 490 | @longnt80 |http://www.freecodecamp.com/longnt80
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:28 UTC
@kumquatfelafel thank you
CamperBot
@camperbot
Aug 10 2017 03:28 UTC
ma5one1 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 590 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Long Nguyen
@longnt80
Aug 10 2017 03:28 UTC
@ma5one1 :smile:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:30 UTC

@ma5one1 ?is known as "conditional", or sometimes "ternary", operator.

you can think of it a bit like.... ordinarily, when you do comparison like a === b, the result of this will be true or false.

but with ternary operator,

a === b ? resultWhenTrue: resultWhenFalse

instead of true or false, it will have resultWhenTrue or resultWhenFalse.

e.g.

var i = 7;
var j = i < 10 ? "i is less than 10" : "i is greater than or equal to 10";
var k = i < 5 ? "i is less than 5" : "i is greater than or equal to 5";
console.log(j); // outputs i is less than 10
console.log(k); // outputs i is greater than or equal to 5
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:31 UTC
@kumquatfelafel so it has two conditions in one line resulting either a true or false outcome
Addison
@addisonday
Aug 10 2017 03:33 UTC
What is a delimeter in Javascript?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:33 UTC
@ma5one1 a bit too tired to parse this, but basically, the "true" result will be to left of the :, and the "false" result will be to the right of the :. It's a bit like the first half is an if, followed by an else, except it's not quite the same
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:34 UTC
Understood. Im actually reading up on it as we speak..
just a matter of when to use it.
:smile:
@kumquatfelafel Danku
Ginger
@GingerChew
Aug 10 2017 03:43 UTC
Is there a way to make an api call with multiple api urls? or do I have to make the api call with every user?
$.getJSON(apiUsersCalls, function(data) {
    $("#streamers").append(
      "<li class='list-group-item'><a target='blank' href='https://www.twitch.tv/" +
        data.name +
        "'>" +
        data.name +
        "</a></li>"
    );
  });
This is what I've got so far, I'm trying to get the api to make the list with each user in the list
Long Nguyen
@longnt80
Aug 10 2017 03:46 UTC
@GingerChew make an array of all user names and loop through it, call the API for each
Ginger
@GingerChew
Aug 10 2017 03:47 UTC
When I tried to do that, it warned me to not do that? but i'll do it again if that's the answer
Long Nguyen
@longnt80
Aug 10 2017 03:54 UTC
what warned you? codepen?
Ginger
@GingerChew
Aug 10 2017 03:54 UTC
@longnt80 it's saying not to make functions inside a loop, but it does do what I'm looking for it to do. Is that an issue?
and yes
Long Nguyen
@longnt80
Aug 10 2017 03:55 UTC
@GingerChew I don't see any warning
Ginger
@GingerChew
Aug 10 2017 03:57 UTC
if you analyze the js it pops up
Long Nguyen
@longnt80
Aug 10 2017 03:59 UTC
with the dev tool?
Ginger
@GingerChew
Aug 10 2017 04:02 UTC
no in the javascript window, theres the chevron with some options there, its in that window
Long Nguyen
@longnt80
Aug 10 2017 04:04 UTC
@GingerChew maybe you were editing it, I just found warning about missing syntax
Ginger
@GingerChew
Aug 10 2017 04:07 UTC
hmmm, maybe, who knows
it's working either way
slertka
@slertka
Aug 10 2017 04:07 UTC
Hi! Looking for a bit of an explanation of the code... I think I understand why it works but would like a explanation?
slertka
@slertka
Aug 10 2017 04:07 UTC
str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
when str = 'thisIsSpinalTap'
why does it return str as 'this Is Spinal Tap'?
I read the documentation on MDN but couldn't quite understand....
Long Nguyen
@longnt80
Aug 10 2017 04:08 UTC
@slertka it's the regexp
@slertka this one /([a-z])([A-Z]) with find any combination of lowercase letter and uppercase letter siting together
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:09 UTC
yeah. $1 represents first capture group ([a-z]), $2 represents second group ([A-Z]).
slertka
@slertka
Aug 10 2017 04:09 UTC
@longnt80 so if i had 3 parenthesized regEx as the first argument, i would need to do '$1 $2 $3' as the second argumnet?
ok, just realized $1 means read only! thanks!
Long Nguyen
@longnt80
Aug 10 2017 04:09 UTC
yes
slertka
@slertka
Aug 10 2017 04:09 UTC
thanks @longnt80 @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 04:09 UTC
slertka sends brownie points to @longnt80 and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 591 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:cookie: 492 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Aug 10 2017 04:10 UTC
@slertka no $1 is for a memory captured, not sure of the right words
for example
with thisIsSpinalTap and the regexp ([a-z])([A-Z])
the first pair will be sI
and $1 is s, and $2 is I
so with this '$1 $2', you will replace sI with s I (space in between)
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:12 UTC

i would need to do '$1 $2 $3' as the second argument?

Depending on what you're trying to do... Maybe? You might include all of them, you might not.

slertka
@slertka
Aug 10 2017 04:12 UTC
@longnt80 not sure I'm following now....
Long Nguyen
@longnt80
Aug 10 2017 04:13 UTC
I know, it's hard to explain
slertka
@slertka
Aug 10 2017 04:13 UTC
I also have a question since the documentation says this is non-standard
Ginger
@GingerChew
Aug 10 2017 04:13 UTC
@longnt80 yep that fixed it and it still works, thanks!
CamperBot
@camperbot
Aug 10 2017 04:13 UTC
gingerchew sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 493 | @longnt80 |http://www.freecodecamp.com/longnt80
slertka
@slertka
Aug 10 2017 04:13 UTC
What are the other options?
Long Nguyen
@longnt80
Aug 10 2017 04:13 UTC
bascially, ([a-z]) is a captured group
the regexp will find the character and remember it
then you can refer to that memorized character by $1
@GingerChew np
slertka
@slertka
Aug 10 2017 04:16 UTC
hmmmm ok
so the example in the documentation
```
var re = /(\w+)\s(\w+)/; var str = 'John Smith'; str.replace(re, '$2, $1'); // "Smith, John" RegExp.$1; // "John" RegExp.$2; // "Smith"
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:16 UTC
this chat is active, may I ask a non related question
slertka
@slertka
Aug 10 2017 04:17 UTC
that makes sense to me, but dont quite the other quote
*example
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:18 UTC

Never!!!! :o

...

@Giveback007 ask away, though can't guarantee answer. :p

Long Nguyen
@longnt80
Aug 10 2017 04:18 UTC
@Giveback007 sure
@slertka it's the same thing with the other
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:19 UTC

Never!!!! :o

:cry:

slertka
@slertka
Aug 10 2017 04:19 UTC
ooohhh i get it
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:19 UTC
@slertka are you asking why the \s doesn't get included?
slertka
@slertka
Aug 10 2017 04:19 UTC
No, I couldn't quite understand how the regex knew to add a space
but now @longnt80 explanation makes sense
Long Nguyen
@longnt80
Aug 10 2017 04:20 UTC
@slertka you got it?
ok
slertka
@slertka
Aug 10 2017 04:20 UTC
yeah!
thanks @longnt80
CamperBot
@camperbot
Aug 10 2017 04:20 UTC
slertka sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: slertka already gave longnt80 points
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:20 UTC
in your opinion if one is done with react, is it better to move on to node.js or is there a practical reason to finish the d3 section?
Long Nguyen
@longnt80
Aug 10 2017 04:21 UTC
@Giveback007 depends on your goal
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:21 UTC
my goal is to get a job
Greg Duncan
@GregatGit
Aug 10 2017 04:21 UTC
@Giveback007 have you used create react app for you projects?
@Giveback007 or webpack?
Long Nguyen
@longnt80
Aug 10 2017 04:22 UTC
then I guess just learn the skills the employers are seeking
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:22 UTC
@GregatGit yeah, but ended up switching to cdn so it would be easier to post the projects on codepen
Joseph
@revisualize
Aug 10 2017 04:22 UTC
@Giveback007 Isn't that everyone's goal.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:23 UTC
@revisualize well, some have jobs
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:23 UTC
My goal is to get money vicariously through other people's jobs! :o
Greg Duncan
@GregatGit
Aug 10 2017 04:23 UTC
@Giveback007 I think it's best to move your projects to github and use webpack or create-react-app to build them
Joseph
@revisualize
Aug 10 2017 04:23 UTC
@Giveback007 It is 923pm and I'm still at mine.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:24 UTC
@GregatGit let's assume I am done with react,
what's better next d3 or node.js
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:24 UTC
'tis 12:45am here, and ima go to bed. :p
Greg Duncan
@GregatGit
Aug 10 2017 04:24 UTC
@Giveback007 you will have to know node
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:25 UTC
@revisualize :fearful:
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:25 UTC
Hey guys, I haven't coded for like a month and I have no idea what I even did here. I just remember I made an AJAX request, and did this api stuff. I forgot how it all works and I don't have a single clue what I can do next:
https://codepen.io/ArchivalBoat50/pen/JyPVbd
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:25 UTC
@ArchivalBoat50 i remember you!!! you said that last time about a month ago :smile:
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:25 UTC
Yeah
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:25 UTC
@revisualize (in case you're wondering, a full 22ish minutes passed between your post and mine. I blame black holes or something)
Night.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:26 UTC
I dont even know anymore
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:26 UTC
@revisualize are you devops?
Joseph
@revisualize
Aug 10 2017 04:26 UTC
@Giveback007 I'm a Network Systems Administrator III.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:26 UTC

@GregatGit

@Giveback007 you will have to know node

that's what I was thinking

ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:26 UTC
@Giveback007 Can you help me out?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:27 UTC
I can't justify learning D3 right now if I am trying to maximize my time
@ArchivalBoat50 I can try
you might want to be more specific @ArchivalBoat50
Joseph
@revisualize
Aug 10 2017 04:27 UTC
@Giveback007 Why do you ask that?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:27 UTC
@revisualize about devops?
Joseph
@revisualize
Aug 10 2017 04:28 UTC
@Giveback007 Yeah, I was kind of wondering why you thought I was DevOps.
I'm just Ops.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:28 UTC
@revisualize because you sound like a secret ops agent!!!
@revisualize (sorry)
because it's 9:30 and you're still at work
Joseph
@revisualize
Aug 10 2017 04:29 UTC
I just spent 5 hours struggling with a service upgrade.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:29 UTC
I talked to a few dev ops guys so far and 2 of them work nights
Joseph
@revisualize
Aug 10 2017 04:30 UTC
I started at 8am.
it's 930pm.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:30 UTC
@revisualize (i am so sorry)
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:30 UTC
@Giveback007 First of all whats the difference between a getJSON and an AJAX call?
Joseph
@revisualize
Aug 10 2017 04:30 UTC
S'sall good.
@ArchivalBoat50 getJSON gets JSON
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:30 UTC
@ArchivalBoat50 well that's a multiplayer answer to it
sometimes people say Ajax when they mean JSON
Joseph
@revisualize
Aug 10 2017 04:30 UTC
@ArchivalBoat50 AJAX isn't just for JSON. You can do a lot of different things with AJAX.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:31 UTC
most apis are done with JSON
@revisualize did I misspeak?
Joseph
@revisualize
Aug 10 2017 04:31 UTC
I don't think so.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:31 UTC
so they're basically just the same function but ajax can do more?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:32 UTC
@ArchivalBoat50 all 4 of the projects you will do here will return JSON objects
Joseph
@revisualize
Aug 10 2017 04:32 UTC
AJAX isn't just for JSON. While a lot of people use AJAX to request JSON data. It's for requesting all types of data in a async manner.
You may use AJAX to get data out of a SQL database.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:33 UTC
so you can use ajax for other different databases?
Joseph
@revisualize
Aug 10 2017 04:33 UTC
@ArchivalBoat50 Or just text.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:33 UTC
@ArchivalBoat50 i think what @revisualize is saying is that it is a way to get all kinds of data
Joseph
@revisualize
Aug 10 2017 04:33 UTC
or RSS
or XML
or more HTML
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "ajax_info.txt", true);
  xhttp.send();
}
See.. This is getting a .txt
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:35 UTC
Oh yeah I forgot, what exactly is XML again?
Joseph
@revisualize
Aug 10 2017 04:35 UTC
@ArchivalBoat50 Kind of like HTML but different.
LOL
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:35 UTC
@ArchivalBoat50 but what you are looking for is to get a JSON object and then use that data to generate twitch streamers
Joseph
@revisualize
Aug 10 2017 04:35 UTC
HTML's Sister language.
@ArchivalBoat50 I'd recommend reading over: https://developer.mozilla.org/en-US/docs/AJAX
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:36 UTC
@revisualize i kind of wish we could write html in XML instead
@revisualize instead of using id's we could use custom elements
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:36 UTC
Yeah my other question would be why my program is not logging the data
Joseph
@revisualize
Aug 10 2017 04:37 UTC
@Giveback007 You can.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:37 UTC
@revisualize ??? !!!
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:38 UTC
@ArchivalBoat50 you are getting an object
i just think you need to do some more to get a series of the objects you want
Capture.PNG
@revisualize tnx for this
CamperBot
@camperbot
Aug 10 2017 04:40 UTC
giveback007 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4423 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 10 2017 04:41 UTC
OMG! Yay! I got 1 brownie point today!
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:41 UTC
@Giveback007 Oh why is there a 400?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:42 UTC
@ArchivalBoat50 i messed around with your code
and broke it for a sec
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:42 UTC
oh
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:42 UTC
here is a hint of the code i used
url: "https://wind-bow.glitch.me/twitch-api/"+type+"/"+chnl,
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:43 UTC
gave me a 403?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:43 UTC
can you take a screen shot?
how do you send an image on gitter?
Long Nguyen
@longnt80
Aug 10 2017 04:46 UTC
drag and drop on here
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:46 UTC
@ArchivalBoat50 lol you just coppy pasted my code
it was a hint
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:46 UTC
windbow403.jpg
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:46 UTC
I also had variables in there
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:46 UTC
there we go
I didn't do anything
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:47 UTC
Capture.PNG
you have undefined variables from
url: "https://wind-bow.glitch.me/twitch-api/"+type+"/"+chnl,
type and chnl are arguments in a reusable function
you have to create something similar for your project
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:48 UTC
???
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:49 UTC
@ArchivalBoat50 looks like you've been away from coding a little bit too long
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:49 UTC
oh wait
whats this wind-bow thing
I kind of know what you mean't
Long Nguyen
@longnt80
Aug 10 2017 04:50 UTC
@ArchivalBoat50 wind-bow just a url
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:50 UTC
@ArchivalBoat50 free code camp has their own api link for helping you
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:51 UTC
oh yeahhhh
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:51 UTC
@ArchivalBoat50 because twich sometimes switches up the way their api works and messes everyone up
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:52 UTC
so i need to change some things
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:52 UTC
@ArchivalBoat50 you need to read over again how to interface with the api
each streamer has a different id
you will need to pass that on in to the url string before you make an ajax call for each one
Long Nguyen
@longnt80
Aug 10 2017 04:53 UTC
@ArchivalBoat50 use this:
https://wind-bow.glitch.me/twitch-api/users/<<account name>>
https://wind-bow.glitch.me/twitch-api/channels/<<account name>>
https://wind-bow.glitch.me/twitch-api/streams/<<account name>>>
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:55 UTC
I think I need to do some learning as well, I will go on to doing node now. Tnx for the conversation everyone
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:55 UTC
@Giveback007 Ok thx for your help
CamperBot
@camperbot
Aug 10 2017 04:55 UTC
archivalboat50 sends brownie points to @giveback007 :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @giveback007 |http://www.freecodecamp.com/giveback007
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:55 UTC
@ArchivalBoat50 np
before I go, does anyone have a justification on why I should learn D3 first?
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:57 UTC
Ok so this windbow url thing is the exact same thing as the original twich url. Contains Same objects same stuff?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:58 UTC
@ArchivalBoat50 it will give you the objects you need to finish the project
it's provided by free code camp for that purpose
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:05 UTC
@longnt80 Ok once I have the links how exactly do I do like a getJSON from it or something?
Long Nguyen
@longnt80
Aug 10 2017 05:09 UTC
@ArchivalBoat50
$.getJSON('https://wind-bow.glitch.me/twitch-api/streams/' + user, function(data){
// do your stuffs
});
Ananda Johnson
@Sovember
Aug 10 2017 05:10 UTC
Hi guys. I have a question about the Javascript "Weather App Challenge" basically I'm trying to use Jquery to access a JSON "location identifier" but I keep getting this message in the console when I try to log the object : "he 'Access-Control-Allow-Origin' header contains multiple values 'https://s.codepen.io, *', but only one is allowed." Any idea what's happening and what I can do to remedy this? Thanks for any insight!!
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:13 UTC
@longnt80 @longnt80 Ok do I have to do write like 3 of those getJSON things or is there a way to do that function for all three of the URL's?
Long Nguyen
@longnt80
Aug 10 2017 05:14 UTC
@ArchivalBoat50 you need to put the usernames into an array, and loop through it
so call the API for each username
Tai Jones
@taiJones00
Aug 10 2017 05:15 UTC
so i'm using an api for the random quote machine project but there's no instructions that tell me how to use the api. Like there's examples of what works but nothing to explain the specific parts that cause it to work
Is there something that explains this?
Long Nguyen
@longnt80
Aug 10 2017 05:16 UTC
@taiJones00 often the api provider will give you the instruction
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:23 UTC

@longnt80

for(var i=0; var i< streamers.length; i++){
  $.getJSON('https://wind-bow.glitch.me/twitch-api/streams/' + streamers, function(data){
  console.log(data);
});
}

Kind of like that?

Long Nguyen
@longnt80
Aug 10 2017 05:24 UTC
@ArchivalBoat50 yes
Markus Kiili
@Masd925
Aug 10 2017 05:25 UTC
@ArchivalBoat50 Maybe you need to use different url's with those calls?
Use streamers[i] or something.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:26 UTC
oh oops i forgot to iterate
How come nothing is being logged?
Markus Kiili
@Masd925
Aug 10 2017 05:29 UTC
@ArchivalBoat50 Check for errors on the browser developer tools console.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:30 UTC
Ok when I use the browers developer tools it shows a bunch of objects but when I use codepen's console it shows nothing
Don't see any errors though with the browser developer tools
Also there are three links do I do three of those getJSON functions?
Long Nguyen
@longnt80
Aug 10 2017 05:32 UTC
@ArchivalBoat50 codepen's console doesn't show as much as the browser's console
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:33 UTC
The three links, do I put three of those getJSON functions?
Long Nguyen
@longnt80
Aug 10 2017 05:34 UTC
@ArchivalBoat50 that's 3 ways to get info from a twitch user, you just need to use what you need
for me I used streams and channels
just open the 3 urls from the same account/user to see the information they provide
@Masd925 Promise is a ES6 feature, so do I need to use babel/polyfill to use it or I can use it normally?
Markus Kiili
@Masd925
Aug 10 2017 05:39 UTC
@longnt80 Depends on the project. Most production front JS still needs to be transpiled into ES5.
For your personal projects, you can use ES6 if you like.
Long Nguyen
@longnt80
Aug 10 2017 05:40 UTC
@Masd925 let say I just want to experiment Promise in 1 of my project, do I have to set up anything?
Markus Kiili
@Masd925
Aug 10 2017 05:41 UTC
Long Nguyen
@longnt80
Aug 10 2017 05:42 UTC
@Masd925 thank you
CamperBot
@camperbot
Aug 10 2017 05:42 UTC
longnt80 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4398 | @masd925 |http://www.freecodecamp.com/masd925
Thayyeb salim
@Thayyebsalim
Aug 10 2017 07:01 UTC
That's the most cookies I've seen
Well done @Masd925
Mohammed Boudad
@matrixersp
Aug 10 2017 07:23 UTC
When your code works but you don't know why lol
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  arr = arr.filter(function(word) {
    return word != false && word != null && word != 0 && word != "" && word != undefined && word === word;
  });
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Markus Kiili
@Masd925
Aug 10 2017 07:26 UTC
@Tekkie7 Filter keeps those arr elements that return a truthy value when passed into the callback function. So here it will keep all the truthy elements.
Mohammed Boudad
@matrixersp
Aug 10 2017 07:26 UTC
I used IsNaN() function and it didn't work, and when I compared word with itself, it did work
Markus Kiili
@Masd925
Aug 10 2017 07:26 UTC
@Tekkie7 NaN is the only JS value not equal to itself, so word===word tests a value for not being NaN.
Mohammed Boudad
@matrixersp
Aug 10 2017 07:27 UTC
Okay, Thanks @Masd925
CamperBot
@camperbot
Aug 10 2017 07:27 UTC
tekkie7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4400 | @masd925 |http://www.freecodecamp.com/masd925
Long Nguyen
@longnt80
Aug 10 2017 07:27 UTC
@Masd925 nice
Markus Kiili
@Masd925
Aug 10 2017 07:27 UTC
@Tekkie7 Your filter callback does the same as the built-in Boolean function, so you could use it instead.
Long Nguyen
@longnt80
Aug 10 2017 07:27 UTC
@Masd925 Boolean is too easy
Markus Kiili
@Masd925
Aug 10 2017 07:27 UTC
Or you could just return word; from the callback.
Mohammed Boudad
@matrixersp
Aug 10 2017 07:29 UTC
Oh! yeh right, thanks again @Masd925
CamperBot
@camperbot
Aug 10 2017 07:29 UTC
tekkie7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: tekkie7 already gave masd925 points
Markus Kiili
@Masd925
Aug 10 2017 07:29 UTC
@longnt80 Filter has automatic coercion to type Boolean, so passing in Boolean is somewhat like holding tweezers holding tweezer, but gets compact solution.
Ccs99817
@ccs99817
Aug 10 2017 07:58 UTC

HELLLLLLLP!!! I am doing the Diff Two Arrays https://www.freecodecamp.org/challenges/diff-two-arrays

function deleteFromArr(string, Array){
  var indexOfStringInArray = Array.indexOf(string);
  Array.splice(indexOfStringInArray, 1);
}


function diffArray(arr1, arr2) {
  var newArr = [];
  var slagArr1 = arr1;
  var slagArr2 = arr2;

  for (var j=0; j<arr1.length; j++){
    var word1 = arr1[j];
    for (var i=0; i<arr2.length; i++){
      var word2 = arr2[i];
      // If the word appears in both arr1 and arr2
      if (word1 == word2){
        //Remove the duplicate text in array 1
        deleteFromArr(word1, slagArr1);
        //Remove the duplicate text in array 2
        deleteFromArr(word2, slagArr2);
      }
    }
  }
  //Combine two slag Array
  newArr = slagArr1.concat(slagArr2);

  return newArr;
}

diffArray(["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"]);

I don't know why the result is so strange.

I suppose the result should be a blank [ ].
but the result is ["grass", "dead shrub","grass", "dead shrub"]
Tiago Correia
@tiagocorreiaalmeida
Aug 10 2017 08:01 UTC
gm everyone
Bartosz
@CataciD
Aug 10 2017 08:04 UTC
woowow gm
anyone needs helps?D:
Ccs99817
@ccs99817
Aug 10 2017 08:05 UTC
@CataciD I need
Bartosz
@CataciD
Aug 10 2017 08:05 UTC
yeah im reading
i dunno if splice is good in that case
you might not understand how the method works
splice and slice work diff
splice afaik is used to RETURN the thing you cut out
and your function should return something if you're set on using that function
but imho you could just slice em
Ccs99817
@ccs99817
Aug 10 2017 08:06 UTC
i want to remove an item in the array
Bartosz
@CataciD
Aug 10 2017 08:07 UTC
ye i know
wiat i need to check it
Ccs99817
@ccs99817
Aug 10 2017 08:07 UTC
then, i guess using splice is better although i do not need to return
Bartosz
@CataciD
Aug 10 2017 08:08 UTC
well
the thing is
i dont like what you're doing
as in
in general
if you give something as a variable to a function
Pieter Stokkink
@forkerino
Aug 10 2017 08:08 UTC
harsh
:D
Bartosz
@CataciD
Aug 10 2017 08:08 UTC
dont modify it
only use it as data
so the best way to do this kind of thing would be to pass the array to function, inside make a copy and operate on it, return that copy
but in the case of this example i feel
you could just replace the function entirely with array.splice()
just make one loop
Pieter Stokkink
@forkerino
Aug 10 2017 08:09 UTC
@ccs99817 why not .filter?
Bartosz
@CataciD
Aug 10 2017 08:09 UTC
yeah filter is also good
even better
Ccs99817
@ccs99817
Aug 10 2017 08:09 UTC
@forkerino i have no idea how to use it lol
Bartosz
@CataciD
Aug 10 2017 08:09 UTC
filter is easy
filter goes through all elements
Pieter Stokkink
@forkerino
Aug 10 2017 08:10 UTC
@ccs99817 good time to learn!
Bartosz
@CataciD
Aug 10 2017 08:10 UTC
leaves them in array if the result of the function
is true
so all you have to do with filter
Ccs99817
@ccs99817
Aug 10 2017 08:10 UTC
oic
Bartosz
@CataciD
Aug 10 2017 08:10 UTC
is check if the currently checked element is !indexOf(element) of the other table
i think
Ccs99817
@ccs99817
Aug 10 2017 08:11 UTC
oh, i think i get it
Bartosz
@CataciD
Aug 10 2017 08:11 UTC
and to be sure i'd operate on the lengthiest array tho
otherwise you might skip something i think
Ccs99817
@ccs99817
Aug 10 2017 08:12 UTC
can i use the filter function twice to ensure nothing is skipped?
Pieter Stokkink
@forkerino
Aug 10 2017 08:13 UTC
@ccs99817 if you .concat first, you only have to .filter once.
Bartosz
@CataciD
Aug 10 2017 08:15 UTC
with concat you would have to figure out a way
to remove duplicates
Ccs99817
@ccs99817
Aug 10 2017 08:16 UTC
how can i find the occurrence of an item in the array?
Pieter Stokkink
@forkerino
Aug 10 2017 08:16 UTC
.indexOf, .includes
@CataciD you can still access the original arrays after .concat
Ccs99817
@ccs99817
Aug 10 2017 08:17 UTC
Isn't .indexOf is used to find the index of the fist occurrence?
Bartosz
@CataciD
Aug 10 2017 08:17 UTC
ofc
but thats my point
indexof will find the first instance
logic is kinda ech
maybe im just bad
id just stick to filter
if you pick the longest array
you wont miss anything
Pieter Stokkink
@forkerino
Aug 10 2017 08:18 UTC
@CataciD @ccs99817 inside .filter, you still need to use .indexOf / .includes
Bartosz
@CataciD
Aug 10 2017 08:18 UTC
yes but you use it on an array that has only one occurance
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:19 UTC
@ccs99817 I would not call your parameter Array. What if you have to do something like, e.g., Array.isArray()? This is confusing.
Ccs99817
@ccs99817
Aug 10 2017 08:19 UTC
@CataciD even if you choose the longest one, you might still skip sth
Pieter Stokkink
@forkerino
Aug 10 2017 08:19 UTC
you have to check if the element is either NOT in arr1 OR NOT in arr2
Jefferson
@jeffersonnnn
Aug 10 2017 08:19 UTC

hi guys, i am stuck at the Mutations bonfire challenge. I need help clarifying the example as is given in the devdocs illustration of indexOf.

Here is the example

```js

Bartosz
@CataciD
Aug 10 2017 08:19 UTC
@ccs99817 example?
Pieter Stokkink
@forkerino
Aug 10 2017 08:19 UTC
@kumquatfelafel What up kumquat?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:20 UTC
@forkerino hey, not much. you?
Bartosz
@CataciD
Aug 10 2017 08:20 UTC
if you have the longest array and loop through its elements with forEach,
you use filter to check if each element is present in the other one
if its not then you leave it
if it is, then false -> remove
Pieter Stokkink
@forkerino
Aug 10 2017 08:20 UTC
@kumquatfelafel Have a day off. Need to find a house.
Ccs99817
@ccs99817
Aug 10 2017 08:21 UTC
@CataciD What if there is an unique item in the shortest array?
Bartosz
@CataciD
Aug 10 2017 08:21 UTC
ye
jsut thought about that
thats the only case
so the concat is the only way
or go through both arrays with a filter
Ccs99817
@ccs99817
Aug 10 2017 08:21 UTC
yup
Bartosz
@CataciD
Aug 10 2017 08:22 UTC
tho if i remember correctly
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:22 UTC
looking for somewhere closer?
Jefferson
@jeffersonnnn
Aug 10 2017 08:22 UTC

hi guys, i am stuck at the Mutations bonfire challenge. I need help clarifying the example as is given in the devdocs illustration of indexOf.

Here is the example

var indices = [];
var array = ['a', 'b', 'a', 'c', 'a', 'd'];
var element = 'a';
var idx = array.indexOf(element);
while (idx != -1) {
  indices.push(idx);
  idx = array.indexOf(element, idx + 1);
}
console.log(indices);
// [0, 2, 4]

I need help the conditional statement in the while loop. Help, please?

Bartosz
@CataciD
Aug 10 2017 08:22 UTC
i usually just did it a bit around
i made a new array
concat tho others
Pieter Stokkink
@forkerino
Aug 10 2017 08:22 UTC
@kumquatfelafel yeah, around the Hague. In Amsterdam now.
Bartosz
@CataciD
Aug 10 2017 08:22 UTC
loop through the concat and check if its present in the array that i made
if its not, add it
that way you go through everything
you can use reduce for that
array.reduce(<concated>, function(){}, result)
afaik
Ccs99817
@ccs99817
Aug 10 2017 08:24 UTC
Thank you guys. I think I can handle it now
@CataciD @forkerino
CamperBot
@camperbot
Aug 10 2017 08:24 UTC
:cookie: 419 | @catacid |http://www.freecodecamp.com/catacid
:star2: 2917 | @forkerino |http://www.freecodecamp.com/forkerino
ccs99817 sends brownie points to @catacid and @forkerino :sparkles: :thumbsup: :sparkles:
Pieter Stokkink
@forkerino
Aug 10 2017 08:24 UTC
:+1:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:24 UTC
@jeffersonnnn I could be groggy from just waking up, but this looks like it should work fine to me?
Pieter Stokkink
@forkerino
Aug 10 2017 08:25 UTC
@jeffersonnnn .indexOf returns -1 if an element is NOT in the array
the second argument is the starting index
i.e. from where it starts looking for the element
This code finds the first occurrence, then looks for the next one and the next one and the next one... Until there are no more occurrences
Long Nguyen
@longnt80
Aug 10 2017 08:27 UTC
@kumquatfelafel good morning :D
Jefferson
@jeffersonnnn
Aug 10 2017 08:28 UTC
@kumquatfelafel haha i assure you, your cognitive abilities are in full force. It does work. i just need help ūnðerstanding that while statement, especially the conditional statement
WAINGOR
@WAINGOR
Aug 10 2017 08:28 UTC

Hi all, I have a question... I am trying to mess around with the Date object... However if I go

var myDate = new Date();

The browser console logs an error...

kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:28 UTC
@longnt80 it's ... slightly pitch black still, but I guess this is good enough haha
WAINGOR
@WAINGOR
Aug 10 2017 08:29 UTC
and now it doesnt.. dafuq
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:29 UTC
@jeffersonnnn yeah, just realized misreading.
Pieter Stokkink
@forkerino
Aug 10 2017 08:29 UTC
@WAINGOR :wave:
Long Nguyen
@longnt80
Aug 10 2017 08:29 UTC
@WAINGOR maybe you just type too fast
WAINGOR
@WAINGOR
Aug 10 2017 08:30 UTC
Hi Pieter
U seem a lot more talkative on Gitter than on fb ;) @forkerino
@longnt80 lucky luke aint got s.hit on me
Pieter Stokkink
@forkerino
Aug 10 2017 08:30 UTC
@WAINGOR sorry.
@WAINGOR I assure you I just arrived here myself.
;)
WAINGOR
@WAINGOR
Aug 10 2017 08:31 UTC
np np :)
Long Nguyen
@longnt80
Aug 10 2017 08:31 UTC
@WAINGOR nice, my favourite childhood character
Pieter Stokkink
@forkerino
Aug 10 2017 08:31 UTC
@WAINGOR any chance for a meetup this weekend?
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:31 UTC
@forkerino Hello :wave:
Pieter Stokkink
@forkerino
Aug 10 2017 08:31 UTC
@abhinav-thinktank Hi
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:31 UTC
So im currently on the React game of life app
im wondering
the state management seems complicated for this one
should i approach redux
WAINGOR
@WAINGOR
Aug 10 2017 08:32 UTC
@forkerino saturday? :) I'll text the boys and see who's willing
Pieter Stokkink
@forkerino
Aug 10 2017 08:32 UTC
Still have to do that one. I was thinking of using Redux.
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:32 UTC
for this?
yeah me too
:O
Pieter Stokkink
@forkerino
Aug 10 2017 08:32 UTC
@WAINGOR I'm game!
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:32 UTC
Anybody who's done the game of life here
Pieter Stokkink
@forkerino
Aug 10 2017 08:32 UTC
@abhinav-thinktank Haven't had much time for FCC since I got hired.
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:32 UTC
aah.
@forkerino nice :D
should i approach redux for this
or should i try and do it in react
Pieter Stokkink
@forkerino
Aug 10 2017 08:33 UTC
@abhinav-thinktank I know it is possible without Redux, but it might make things easier.
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:33 UTC
hmm
i guess i'll learn alot if i do it in react
but at the same time i dont wanna miss out on learning redux
:smile:
Pieter Stokkink
@forkerino
Aug 10 2017 08:34 UTC
@abhinav-thinktank decisions, decisions!
Jefferson
@jeffersonnnn
Aug 10 2017 08:34 UTC
@forkerino thank you! Alas, i see this, i am looking for an explanation of the conditional statement in the while loop. Tsuck at the mutations bonfire. Thanks!
CamperBot
@camperbot
Aug 10 2017 08:34 UTC
:star2: 2918 | @forkerino |http://www.freecodecamp.com/forkerino
jeffersonnnn sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:34 UTC
@forkerino true :D
i've just done example projects in react
apart from the fcc stuff i mean
Pieter Stokkink
@forkerino
Aug 10 2017 08:35 UTC
@jeffersonnnn while (idx !== -1) basically says 'while there is another occurrence of the element in the array'
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:35 UTC
hmm.. i guess ill try to think of a structure to the app and if it gets too complicated i'll try redux
WAINGOR
@WAINGOR
Aug 10 2017 08:35 UTC
My dear fellow coders, allow me to confess something in the midst of all this code-crunching : I rlly like this song : https://www.youtube.com/watch?v=SYM-RJwSGQ8
Pieter Stokkink
@forkerino
Aug 10 2017 08:35 UTC
@abhinav-thinktank what data were you thinking of storing?
WAINGOR
@WAINGOR
Aug 10 2017 08:35 UTC
pls forgive
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:35 UTC
@forkerino won't i need a matrix
Pieter Stokkink
@forkerino
Aug 10 2017 08:36 UTC
@abhinav-thinktank like a 2d array?
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:36 UTC
yea
Pieter Stokkink
@forkerino
Aug 10 2017 08:36 UTC
yes
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:36 UTC
@forkerino im wondering how im gonna utilize components in this for state change
Pieter Stokkink
@forkerino
Aug 10 2017 08:36 UTC
how would the elements look? Will you just store 1/0 for alive/dead?
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:36 UTC
yes thats what im thinking so far
but the thing is , i need to assign components
say the whole thing is contained in a 2d array as state in a main component
now simulating live and dead cells
Pieter Stokkink
@forkerino
Aug 10 2017 08:37 UTC
yes
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:37 UTC
do i constantly keep on changing this main component?
i mean it's state?
im not sure if thats the way to go
Jefferson
@jeffersonnnn
Aug 10 2017 08:38 UTC
@forkerino just that? Amazingly concise. Thank you plenty much.
CamperBot
@camperbot
Aug 10 2017 08:38 UTC
jeffersonnnn sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: jeffersonnnn already gave forkerino points
Pieter Stokkink
@forkerino
Aug 10 2017 08:38 UTC
:+1:
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:38 UTC
or should i make a main component
Pieter Stokkink
@forkerino
Aug 10 2017 08:38 UTC
@abhinav-thinktank I think that would be easiest (and it's one of the reasons I would use Redux)
to have state at top level
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:38 UTC
set the 2d array as its state and pass it down to a rendering component as props
but this would cause even more clutter
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:39 UTC

@jeffersonnnn You can think of indexOf as operating kinda like this...

function(element, start = 0) {
  for (var i = start; i < this.length; i++ {
    if (this[i] === element)
      return i;
  }
  return -1;
}

where this is the array or string in question. So basically, it returns -1 when the element is not found.

Abhinav Mishra
@abhinav-m
Aug 10 2017 08:39 UTC
@forkerino my apps so far have been poor in structure :(
so im gonna think about this before i engineer it
:D
Pieter Stokkink
@forkerino
Aug 10 2017 08:39 UTC
@abhinav-thinktank that's part of learning. Don't worry, even professionals make poorly structured code sometimes. :laughing:
Jefferson
@jeffersonnnn
Aug 10 2017 08:39 UTC
@WAINGOR you are banished to the netherworlds of lodash.js and hammer.js never to know the pure hue of vanilla.js, never to know forgiveness 😁
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:39 UTC
@forkerino yeah :D well thanks!
CamperBot
@camperbot
Aug 10 2017 08:39 UTC
abhinav-thinktank sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2919 | @forkerino |http://www.freecodecamp.com/forkerino
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:40 UTC
Im enjoying react now
in baby steps :P
WAINGOR
@WAINGOR
Aug 10 2017 08:40 UTC
@jeffersonnnn WAIT. PLS DONT. I'M SORRY OK
Pieter Stokkink
@forkerino
Aug 10 2017 08:40 UTC
@abhinav-thinktank I like it too. Mostly using Angular now and I'm not a big fan
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:40 UTC
aah
Pieter Stokkink
@forkerino
Aug 10 2017 08:40 UTC
But at least we use redux
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:40 UTC
cool :+1:
WAINGOR
@WAINGOR
Aug 10 2017 08:40 UTC
I luvvvvvv Node
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:40 UTC
nice
WAINGOR
@WAINGOR
Aug 10 2017 08:41 UTC
finishing up my first programme in it
Pieter Stokkink
@forkerino
Aug 10 2017 08:41 UTC
@WAINGOR woot woot
@WAINGOR for FCC? or something else?
WAINGOR
@WAINGOR
Aug 10 2017 08:41 UTC
it's a private project that I am making for my dad's store @forkerino
Pieter Stokkink
@forkerino
Aug 10 2017 08:42 UTC
coolcoolcool
WAINGOR
@WAINGOR
Aug 10 2017 08:42 UTC
modules are so easy to find
they do lots of the work for ya... it can be a bit tricky to mix them up and have them interact but nothing an ambitious camper can't handle
Pieter Stokkink
@forkerino
Aug 10 2017 08:42 UTC
sure thing!
Jefferson
@jeffersonnnn
Aug 10 2017 08:43 UTC
@kumquatfelafel hmm. extra insight. i love how you did this. Thank you too. FCC rocks.
CamperBot
@camperbot
Aug 10 2017 08:43 UTC
jeffersonnnn sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 592 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Jefferson
@jeffersonnnn
Aug 10 2017 08:44 UTC
@WAINGOR LMAO
Pieter Stokkink
@forkerino
Aug 10 2017 08:45 UTC
@WAINGOR are you building something complete with payment processing and stuff?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:45 UTC
Full disclosure though, missing a )... but didn't feel like editing. More conceptual than "useful" anyway :p
off for a bit.
WAINGOR
@WAINGOR
Aug 10 2017 08:46 UTC
@forkerino no... all it does is scan the web and sends e-mails about valuable information it has found. Information valuable to my dad's business that is
@forkerino told U about it before :) but U thought in terms of spamming. its not rlly like that
Pieter Stokkink
@forkerino
Aug 10 2017 08:48 UTC
ah, I think I get it now
Theofanis Despoudis
@theodesp
Aug 10 2017 09:00 UTC
Pieter Stokkink
@forkerino
Aug 10 2017 09:00 UTC
@theodesp looks familiar
:laughing:
Abhishek Kumar Pandey
@abhishekpandeykr
Aug 10 2017 09:01 UTC
hello guys, need help, i want to upload profile picture in angular-4 , don't know how to start, any tutorial will be great
Theofanis Despoudis
@theodesp
Aug 10 2017 09:01 UTC
visit the Angular 4 channel
Abhishek Kumar Pandey
@abhishekpandeykr
Aug 10 2017 09:03 UTC
@theodesp i did bro!
LovingVi
@LovingVi
Aug 10 2017 09:06 UTC

'''js
function slasher(arr, num) {
if(num > arr.length){
return arr = [];
}else{
return arr = arr.splice(0,num);
}
}

slasher([1, 2, 3], 2);
'''
it return [1,2],but I want to get [3]. What's wrong with it?

CamperBot
@camperbot
Aug 10 2017 09:06 UTC
:bulb: to format code use backticks! ``` more info
Markus Kiili
@Masd925
Aug 10 2017 09:08 UTC
@LovingVi Splice return value is a new array made from removed elements.
So don't assign the return value to arr.
Also check whether you need such an if check.
LovingVi
@LovingVi
Aug 10 2017 09:12 UTC
@Masd925 TKS
/'''js
code
/'''
CamperBot
@camperbot
Aug 10 2017 09:16 UTC
:bulb: to format code use backticks! ``` more info
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:33 UTC

@LovingVi ```, not '''.

try typing the lines below :point_down: exactly as they appear...
```js
code
```

CamperBot
@camperbot
Aug 10 2017 09:33 UTC
:bulb: to format code use backticks! ``` more info
Mark Mascarenhas
@Freedom41
Aug 10 2017 09:35 UTC

``` can someone help me

function mutation(arr) {
var a = arr[0];
var b = arr[1];
var c = a.toLowerCase().split("");

var d = b.toLowerCase().split("");

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

var x = c.indexOf(d[i]);

if (x === -1) {
  return false;
  }
else {
    return true;
    }
}

}

mutation(["hello", "hey"]);
```
👆🏽
Every value is correct except for this ☹

Sorry about the backticks... I'm messaging from mobile.
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:40 UTC
@Freedom41 you're returning too early.
Brian
@BrianCodes33
Aug 10 2017 09:41 UTC
any JS pros
Mark Mascarenhas
@Freedom41
Aug 10 2017 09:41 UTC
only 4 challenges left from basic algorithms :D......
for mutations im getting everything coreect except for the first one.....
Markus Kiili
@Masd925
Aug 10 2017 09:46 UTC
@Freedom41 Are you looping the second string characters?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:46 UTC

@Freedom41 Actually, it would probably be more accurate to say that the others are "accidentally correct". Try running this and look at what pops up in console. https://repl.it/KE8u

Is it checking all the letters?

for (var i = 0; i < 10; i++) {
  return 5; // this return statement is not executed 10 times. It is only executed once.
}
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:52 UTC
@BrianCodes33 either someone will be able to answer question, or won't. Hard to say without seein' it ;)
Brian
@BrianCodes33
Aug 10 2017 09:52 UTC
function arrAdder(arr) {

}

arrAdder([
['J','L','L','M'],
['u','i','i','a'],
['s','v','f','n'],
['t','e','e','']
])
arrAdder([
['J','L','L','M'],
['u','i','i','a'],
['s','v','f','n'],
['t','e','e','']
]) // => "Just Live Life Man”
Mark Mascarenhas
@Freedom41
Aug 10 2017 09:52 UTC
I get it :) Thanks so much @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 09:52 UTC
freedom41 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 593 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:54 UTC
@BrianCodes33 so basically, operating on columns as opposed to rows, yes?
Brian
@BrianCodes33
Aug 10 2017 09:54 UTC
yea
Mark Mascarenhas
@Freedom41
Aug 10 2017 09:54 UTC
@Masd925 the code is not checking all letters
Ill try now Thanks :)
Brian
@BrianCodes33
Aug 10 2017 09:55 UTC
started getting somewhere thinking i needed an array of arrays then got stuck
function arrAdder(arr) {
  var output = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
    }
  }
  return output.join('');
}
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:55 UTC
@BrianCodes33 We can start off with a relatively basic solution, and from there, I'll let you decide if you want to try for something more elegant.
... okay.
So... what is the row index and column index of 'J'. How about row index and column index of 'u'? 's'? 't'?
Brian
@BrianCodes33
Aug 10 2017 09:58 UTC
[0][0]
[1][0]
etc..
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:59 UTC
So i is changing, but j is not.
Brian
@BrianCodes33
Aug 10 2017 09:59 UTC
right
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:59 UTC
Now in your inner for loop, which is changing? j or i?
Brian
@BrianCodes33
Aug 10 2017 10:00 UTC
j
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:00 UTC
do we want j to be the one that's changing?
Brian
@BrianCodes33
Aug 10 2017 10:00 UTC
no
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:01 UTC
yeah, so we want to change i, right?
(stop me if you see where I'm going with this)
Brian
@BrianCodes33
Aug 10 2017 10:01 UTC
i see what i want to do just cant put it in code
function arrAdder(arr) {
  var output = [];
  for (var i = 0; i < arr.length; i++) {
      console.log(arr[i] + 1);
    for (var j = 0; j < arr[i].length; j++) {
//       console.log(arr[i + 1][j]);
    }
  }
  return output.join('');
}
my brain hurts
Pieter Stokkink
@forkerino
Aug 10 2017 10:05 UTC
@BrianCodes33 normally in nested loops you go left to right (inner loop), top to bottom (outer loop) through the nested array. In your case you want to reverse that somehow.
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:05 UTC
:point_up:
Brian
@BrianCodes33
Aug 10 2017 10:09 UTC
Ok
why do i want to reverse
Pieter Stokkink
@forkerino
Aug 10 2017 10:10 UTC
because you need to go top to bottom, left to right to make the sentence out of the array
Brian
@BrianCodes33
Aug 10 2017 10:11 UTC
im too tired to think
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:12 UTC

because instead of adding J L L M, you're adding J u s t.

n.b. not reverse in the sense of array's reverse function.

I think, mathematically, a similar concept would be like y = 2x and x = 2y. Or something like that. But forget the name for it.

Pieter Stokkink
@forkerino
Aug 10 2017 10:13 UTC
@BrianCodes33 if you are too tired to think it is time to take a break. :)
Brian
@BrianCodes33
Aug 10 2017 10:13 UTC
yea so normally it goes [0,0] [0,1] [0,2] i want [0,0] [1,0] 2,0]
i did it
haha
Pieter Stokkink
@forkerino
Aug 10 2017 10:14 UTC
:+1:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:14 UTC
grats :)
what did you come up with?
Brian
@BrianCodes33
Aug 10 2017 10:15 UTC
uh oh still failed on codewars
Shorter words will have an empty string in the place once the word has already been mapped out (see the last element in the last element in the array).

Examples:

arrAdder([
['J','L','L','M'],
['u','i','i','a'],
['s','v','f','n'],
['t','e','e','']
]) // => "Just Live Life Man"

arrAdder([ 
  [ 'T', 'M', 'i', 't', 'p', 'o', 't', 'c' ],
  [ 'h', 'i', 's', 'h', 'o', 'f', 'h', 'e' ],
  [ 'e', 't', '', 'e', 'w', '', 'e', 'l' ],
  [ '', 'o', '', '', 'e', '', '', 'l' ],
  [ '', 'c', '', '', 'r', '', '', '' ],
  [ '', 'h', '', '', 'h', '', '', '' ],
  [ '', 'o', '', '', 'o', '', '', '' ],
  [ '', 'n', '', '', 'u', '', '', '' ],
  [ '', 'd', '', '', 's', '', '', '' ],
  [ '', 'r', '', '', 'e', '', '', '' ],
  [ '', 'i', '', '', '', '', '', '' ],
  [ '', 'a', '', '', '', '', '', '' ] ]) // => "The Mictochondria is the powerhouse of the cell”
Pieter Stokkink
@forkerino
Aug 10 2017 10:16 UTC
Did you add spaces between the words?
Brian
@BrianCodes33
Aug 10 2017 10:16 UTC
gotta split it
function arrAdder(arr) {
  var output = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      output.push(arr[j][i]);
    }
  }
  return output.join('');
}
Expected: 'Just Live Life Man', instead got: 'JustLiveLifeMan'
Expected: 'The Mitochondria is the powerhouse of the cell', instead got: 'TheMitochonisthepowerhouofthecell'
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:18 UTC
@BrianCodes33 it's because not everything is a "square" array.
Brian
@BrianCodes33
Aug 10 2017 10:18 UTC
right there are empty strings
hmm
Pieter Stokkink
@forkerino
Aug 10 2017 10:19 UTC
@BrianCodes33 you have to add a space between the words (i.e. after the inner loop)
except after the last word
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:19 UTC
:point_up: this too.
Pieter Stokkink
@forkerino
Aug 10 2017 10:19 UTC
The empty strings shouldn't matter
Brian
@BrianCodes33
Aug 10 2017 10:23 UTC
hmm
brains not working
how do i access word if im iterating over the chars
i am confused
Bartosz
@CataciD
Aug 10 2017 10:26 UTC
add space after every index change
LUL
in the first array
Brian
@BrianCodes33
Aug 10 2017 10:26 UTC
LUL?
Bartosz
@CataciD
Aug 10 2017 10:26 UTC
lol
Brian
@BrianCodes33
Aug 10 2017 10:26 UTC
are you laughing at me
Bartosz
@CataciD
Aug 10 2017 10:26 UTC
nope
just luling around
you still have the problem you mentioned above?
i was afk
whenever in [x][y] x===0 push a space
heroiczero
@heroiczero
Aug 10 2017 10:29 UTC
@BrianCodes33 do you have a return output.join(' '); "space" for join
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:29 UTC

output.push(arr[j][i]);

@BrianCodes33 This is close, but not quite.

for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      output.push(arr[i][j]); //You may not change this line. It is disallowed :o
    }
}

Suppose you absolutely have to use this code as written... the only thing you can do... is change the location of any given lines of code.

Is there a way we could sort of replicate that idea you had earlier, but without modifying output.push(arr[i][j])?

Brian
@BrianCodes33
Aug 10 2017 10:29 UTC
function arrAdder(arr) {
  var output = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {

      output.push(arr[j][i]);
    }
  }
  return output.join('');
}
Expected: 'Just Live Life Man', instead got: 'JustLiveLifeMan'
Expected: 'The Mitochondria is the powerhouse of the cell', instead got: 'TheMitochonisthepowerhouofthecell'
Bartosz
@CataciD
Aug 10 2017 10:30 UTC
if j===0 output.push(' ')
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:30 UTC
See @heroiczero hint
Pieter Stokkink
@forkerino
Aug 10 2017 10:30 UTC
wouldn't that put spaces between each letter?
Bartosz
@CataciD
Aug 10 2017 10:31 UTC
no
because J
is the first index
arr[j][i]
every time j is 0
it's a begining of a word
that goes vertically down
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:31 UTC
oh wait... pushing each character... nvm. then join won't work. Not without modification anyway.
Bartosz
@CataciD
Aug 10 2017 10:31 UTC
[0][0] is the first word
[0][1] is the second word
and so on
Pieter Stokkink
@forkerino
Aug 10 2017 10:32 UTC
@CataciD sorry was talking about @heroiczero 's hint
Bartosz
@CataciD
Aug 10 2017 10:32 UTC
k
yeah joining here is pointless
Pieter Stokkink
@forkerino
Aug 10 2017 10:32 UTC
I just solved it with map/reduce/join hypercombo
Bartosz
@CataciD
Aug 10 2017 10:32 UTC
cause the arrays contain rows of letters
ye would be the same
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:32 UTC
@forkerino yeah. We were operating off of the "develop words then join" mindset :p
Bartosz
@CataciD
Aug 10 2017 10:32 UTC
brians function is good
only add a condition for pushing space when j===0
Brian
@BrianCodes33
Aug 10 2017 10:33 UTC
tried it @CataciD
Pieter Stokkink
@forkerino
Aug 10 2017 10:33 UTC
or push a space after the inner loop
and trim the result
Bartosz
@CataciD
Aug 10 2017 10:33 UTC
ye same
Brian
@BrianCodes33
Aug 10 2017 10:34 UTC
function arrAdder(arr) {
  var output = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      if (j===0) {
        output.push(' ');
      }
      output.push(arr[j][i]);
    }
  }
  return output.join('');
}
Expected: 'Just Live Life Man', instead got: ' Just Live Life Man'
Expected: 'The Mitochondria is the powerhouse of the cell', instead got: ' The Mitochon is the powerhou of the cell '
Bartosz
@CataciD
Aug 10 2017 10:34 UTC
theres a space at the begining
Pieter Stokkink
@forkerino
Aug 10 2017 10:34 UTC
@BrianCodes33 yeah, it doesn't work with arrays that have different height/width
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:35 UTC
@BrianCodes33 Because output.push(arr[j][i]); Only would work if arr. length === arr[i].length. This is not guaranteed
Bartosz
@CataciD
Aug 10 2017 10:35 UTC
if j===0 && i!==0
do that
Pieter Stokkink
@forkerino
Aug 10 2017 10:35 UTC
because of the order of the loop
s
Brian
@BrianCodes33
Aug 10 2017 10:35 UTC
Test Passed: Value == 'Just Live Life Man'
Expected: 'The Mitochondria is the powerhouse of the cell', instead got: 'The Mitochon is the powerhou of the cell    '
function arrAdder(arr) {
  var output = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      if (j===0&&i!==0) {
        output.push(' ');
      }
      output.push(arr[j][i]);
    }
  }
  return output.join('');
}
Pieter Stokkink
@forkerino
Aug 10 2017 10:36 UTC
@BrianCodes33 yeah, it doesn't work with arrays that have different height/width
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:36 UTC
@BrianCodes33 See what I said earlier. :point_up: August 10, 2017 6:29 AM
Pieter Stokkink
@forkerino
Aug 10 2017 10:36 UTC
First loop over arr[0], inside loop over arr
Brian
@BrianCodes33
Aug 10 2017 10:36 UTC
yea so how do i account for that
Bartosz
@CataciD
Aug 10 2017 10:37 UTC
did you try mine?
did it work
Brian
@BrianCodes33
Aug 10 2017 10:37 UTC
only first test passed @CataciD
Bartosz
@CataciD
Aug 10 2017 10:37 UTC
and the second?
Brian
@BrianCodes33
Aug 10 2017 10:37 UTC
nope
Expected: 'The Mitochondria is the powerhouse of the cell', instead got: 'The Mitochon is the powerhou of the cell '
Bartosz
@CataciD
Aug 10 2017 10:37 UTC
why does it add spaces at the end T.T
Brian
@BrianCodes33
Aug 10 2017 10:37 UTC
because of what @kumquatfelafel said
Pieter Stokkink
@forkerino
Aug 10 2017 10:37 UTC
@BrianCodes33 First loop over arr[0], inside loop over arr
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:38 UTC
:point_up:
Pieter Stokkink
@forkerino
Aug 10 2017 10:38 UTC
that's what I meant with reverse the order of the loops
Brian
@BrianCodes33
Aug 10 2017 10:38 UTC
im confused can you layman’s terms me
@BrianCodes33 First loop over arr[0], inside loop over arr
?
Pieter Stokkink
@forkerino
Aug 10 2017 10:39 UTC
@BrianCodes33 the for loop you have on the inside should be on the outside.
and vice versa
Bartosz
@CataciD
Aug 10 2017 10:39 UTC
um
that would ruin everything
hes doing it
first table first letter
second table first letter
etc
so its good
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:39 UTC
@BrianCodes33 take this line... for (var i = 0; i < arr.length; i++) {.. and switch it with this line... for (var j = 0; j < arr[i].length; j++) { and then yeah :point_down:
Pieter Stokkink
@forkerino
Aug 10 2017 10:39 UTC
and make a 0 out of i
Bartosz
@CataciD
Aug 10 2017 10:40 UTC
that way he will push all the letters first
first letters
the output will be wrong
wont it?
Pieter Stokkink
@forkerino
Aug 10 2017 10:40 UTC
@CataciD maybe the pushing needs to change, but it's the only way to solve
(with loops)
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:40 UTC
yes, the push has to go back to arr[i][j] as opposed to [j][i]
Brian
@BrianCodes33
Aug 10 2017 10:40 UTC
my brain hurts lol
Bartosz
@CataciD
Aug 10 2017 10:41 UTC
why
@kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:42 UTC
@CataciD Because the 2d array might not be square.
Bartosz
@CataciD
Aug 10 2017 10:42 UTC
if hes gonna do [i][j] then push em
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:42 UTC
row length may be different than column length
Bartosz
@CataciD
Aug 10 2017 10:42 UTC
yes
but the point is
he wont push the words
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:42 UTC
so that will mess things up when push [j][i]
you can see it in results. parts of words get chopped off in second test because inner loop doesn't actually execute enough times
Ccs99817
@ccs99817
Aug 10 2017 10:43 UTC
I had completed the Roman Numeral Converter. I want you to give me some advice to improve it as the code seems not efficient. It is so straightforward that no mathematics calculation is used.
function convertToRoman(num) {
  var decNumber = [0,1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,2000,3000];
  var romanNumber = ["","I","II","III","IV","V","VI","VII","VIII","IX","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","M","MM","MMM"];
  num = num + "";
  var numberOfHighestPower = num.length - 1;
  num = num.split('');
  for (var i=0; i<num.length; i++){
    num[i] = parseInt(num[i], 10)*10**(numberOfHighestPower-i);
  }
  for (var j=0; j<num.length; j++){
    var index = decNumber.indexOf(num[j]);
    num[j] = romanNumber[index];
  }

  return num.join('');
}

convertToRoman(36);
Bartosz
@CataciD
Aug 10 2017 10:43 UTC
wont you end up with "TMistpotc hishofhe" and so on?
its an array of arrays
[i][j] will go thrugh all of em?
though i guess
he shouldnt push
omg
nvm
clicked
he's putting them in concrete locations
not pushing
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:45 UTC
... Now I'm confused. :laughing:
Markus Kiili
@Masd925
Aug 10 2017 10:45 UTC
@ccs99817 It would be enough to consider the basis of Roman numerals:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:45 UTC
off for now.
Markus Kiili
@Masd925
Aug 10 2017 10:45 UTC
  var NUM = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
  var ROM = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'];
Pieter Stokkink
@forkerino
Aug 10 2017 10:45 UTC
@ccs99817 You won't need all the intermediate numerals.
heroiczero
@heroiczero
Aug 10 2017 10:45 UTC
@ccs99817 you dont really need all the numbers from 0 to 10 and 10 to 100
Pieter Stokkink
@forkerino
Aug 10 2017 10:45 UTC
i.e. what @Masd925 said
Ccs99817
@ccs99817
Aug 10 2017 10:46 UTC
@heroiczero @forkerino This is the solution come in my mind in short ><
Markus Kiili
@Masd925
Aug 10 2017 10:46 UTC
@forkerino I have a solution that only uses var ROM = [ 'I', 'V', 'X', 'L', 'C', 'D', 'M' ];, but it is not pretty.
Ccs99817
@ccs99817
Aug 10 2017 10:47 UTC
@Masd925 Can u show me that?
Pieter Stokkink
@forkerino
Aug 10 2017 10:47 UTC
@Masd925 I can imagine. My first solution also went about it that way. Lots more logic to add.
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:47 UTC
I have a solution that doesn't use I, V, X, L, C, or any of those unnecessary roman numerals! :o
Pieter Stokkink
@forkerino
Aug 10 2017 10:47 UTC
I remember a huge switch statement
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:47 UTC
But it only works on FCC
Pieter Stokkink
@forkerino
Aug 10 2017 10:48 UTC
@kumquatfelafel I'm intrigued
Ccs99817
@ccs99817
Aug 10 2017 10:48 UTC
@forkerino So, you simply the code when you become more and more mature?
Pieter Stokkink
@forkerino
Aug 10 2017 10:48 UTC
@ccs99817 yes
simplify
and clean it all up
Ccs99817
@ccs99817
Aug 10 2017 10:49 UTC
@forkerino >< sorry for typo.
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:49 UTC
about @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 10:49 UTC
:cookie: 593 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Ccs99817
@ccs99817
Aug 10 2017 10:49 UTC
How long did you get to become mature?
@ccs99817 yes
Pieter Stokkink
@forkerino
Aug 10 2017 10:49 UTC
@ccs99817 message got through anyway. I also replaced almost all for loops with map/reduce/filter/every/some array methods.
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:49 UTC
@forkerino It's also my Map the Debris solution :point_up: :point_up:
Ccs99817
@ccs99817
Aug 10 2017 10:50 UTC
I have thought of map
Pieter Stokkink
@forkerino
Aug 10 2017 10:50 UTC
@kumquatfelafel lol
Ccs99817
@ccs99817
Aug 10 2017 10:51 UTC
But, i forget how to use it
Pieter Stokkink
@forkerino
Aug 10 2017 10:51 UTC
hackz0r
Markus Kiili
@Masd925
Aug 10 2017 10:51 UTC
@kumquatfelafel Your solution seems to be using letter and number arrays. We wan't to see the one that doesn't use Roman letters at all.
Pieter Stokkink
@forkerino
Aug 10 2017 10:51 UTC
@Masd925 check his map the debris 'solution'
CamperBot
@camperbot
Aug 10 2017 10:51 UTC
:cookie: 593 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
heroiczero
@heroiczero
Aug 10 2017 10:52 UTC
Is there a way to use it without letters?
Ccs99817
@ccs99817
Aug 10 2017 10:52 UTC
thx @forkerino @Masd925 @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 10:52 UTC
ccs99817 sends brownie points to @forkerino and @masd925 and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 594 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 2921 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 4401 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 10 2017 10:52 UTC
@kumquatfelafel ok. Nice solution ;)
@ccs99817
function convertToRoman(num) {
  var ROM = [ 'I', 'V', 'X', 'L', 'C', 'D', 'M' ];
  return ROM.reduceRight(function(acc,curr,index){
    var NUM = Math.pow(5,index%2)*Math.pow(10,index/2>>0);
    var SUB = NUM / (5*Math.pow(2,(index+1)%2));
    acc += curr.repeat(num/NUM>>0);
    num -= (num/NUM>>0)*NUM;
    if (num>=NUM-SUB && NUM>1) {
        acc = acc + ROM[(String(SUB).length-1)*2] + curr;
        num-=(NUM-SUB);
    }
    return acc;
  }, '');
}
prakash chandra yadav
@prakashyadav008
Aug 10 2017 10:53 UTC
how to get weather icons in codepen
.?
Pieter Stokkink
@forkerino
Aug 10 2017 10:53 UTC
@Masd925 that's not the easiest to read.
:laughing:
Blauelf
@Blauelf
Aug 10 2017 10:54 UTC
Wow. num and NUM.
Bartosz
@CataciD
Aug 10 2017 10:54 UTC
HERE WE GO
Markus Kiili
@Masd925
Aug 10 2017 10:54 UTC
@forkerino Was this a readability competition. No :rat:
Bartosz
@CataciD
Aug 10 2017 10:54 UTC
two dickwavers gonna fight :D
Ccs99817
@ccs99817
Aug 10 2017 10:55 UTC
@Masd925 tbh, it's a bit hard to read
Pieter Stokkink
@forkerino
Aug 10 2017 10:55 UTC
@Masd925 :smile:
Markus Kiili
@Masd925
Aug 10 2017 10:55 UTC
@ccs99817 Yeah, just made it to prove that it can be done.
Ccs99817
@ccs99817
Aug 10 2017 10:56 UTC
@Masd925 at least, it's efficient
Markus Kiili
@Masd925
Aug 10 2017 10:56 UTC
@ccs99817 Now of course I have to prove that it can be done without an array at all.
Blauelf
@Blauelf
Aug 10 2017 10:59 UTC
There's no IOCCC for JS.
Markus Kiili
@Masd925
Aug 10 2017 11:00 UTC
@ccs99817 I also have a one-liner, but not going to show it to you bullies. Only clean code solutions from now on....snif
Pieter Stokkink
@forkerino
Aug 10 2017 11:00 UTC
:cry:
Bartosz
@CataciD
Aug 10 2017 11:04 UTC

nobully

Blauelf
@Blauelf
Aug 10 2017 11:07 UTC
Now the question is: Does a Bully run on Diesel? If so, when did Volkswagen start cheating?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 11:08 UTC
@forkerino hey... for your kata, how did you go about testing for the length/one line-ness of users solution?
Stephen James
@sjames1958gm
Aug 10 2017 11:11 UTC
@prakashyadav008 Which API are you using for weather
Pieter Stokkink
@forkerino
Aug 10 2017 11:12 UTC

@kumquatfelafel you can read the file with the solution and test the length of the code, I'm sure you can also check for the presence of \n if needed, but in my case that wasn't necessary.

var limit=76;
var fs = require('fs');
var lengthCheck = false;
var code = fs.readFileSync('/home/codewarrior/solution.txt', 'utf8');
var codelen=code.length;
console.log("Your Code:\n",code.replace(/</g,"&lt;").replace(/>/g,"&gt;"));
if (codelen>limit) Test.assertEquals("code length > "+limit,"code length to be <= "+limit,  "Your code length = "+codelen);
else { 
  Test.assertEquals("code length = "+codelen+", code length check passed!","code length = "+codelen+", code length check passed!");
}

I copied it from someone else, and didn't clean up too much,

so it might be made more elegant
kumquatfelafel
@kumquatfelafel
Aug 10 2017 11:13 UTC

ah... perfect! Thanks

so it might be made more elegant

I'll survive. :p ;)

Razvan Jackson
@RazvanJackson
Aug 10 2017 11:31 UTC
Hello
Markus Kiili
@Masd925
Aug 10 2017 11:31 UTC
@RazvanJackson Yo.
Pieter Stokkink
@forkerino
Aug 10 2017 11:31 UTC
Hi
Razvan Jackson
@RazvanJackson
Aug 10 2017 11:32 UTC
What can i do as a beginner, i mean i know html css, some javasc ript / DOM and some php...
Some sugestions?
Pieter Stokkink
@forkerino
Aug 10 2017 11:36 UTC
@RazvanJackson Build stuff. Try to each time make something that is a little more complex than the last thing you built.
Razvan Jackson
@RazvanJackson
Aug 10 2017 11:38 UTC
@forkerino that's what i want, but i don't have any ideea of what can i build, i mean i kinda want to build a webiste, but i don't have any ideea
Markus Kiili
@Masd925
Aug 10 2017 11:41 UTC
@RazvanJackson It is a good idea to look at some pages others have done. https://gitter.im/FreeCodeCamp/CodeReview is full of projects you can look at. At first you tend to copy paste a lot and use templates etc. Then you learn to do thing on your own.
Pieter Stokkink
@forkerino
Aug 10 2017 11:42 UTC

@RazvanJackson FCC has some projects that can be helpful. Also just googling 'projects to learn webdevelopment' will get you lists and lists of things to try, as for example in here: https://www.quora.com/What-are-some-good-projects-ideas-in-web-development-that-a-beginner-can-start-with-to-take-his-her-skills-to-the-next-level

If you want to sharpen your coding skills, sites like codewars have a great collection of puzzles.

Razvan Jackson
@RazvanJackson
Aug 10 2017 11:42 UTC
Thanks guys :)
Blauelf
@Blauelf
Aug 10 2017 11:53 UTC
And I thought it were a unicorn that had to die. What a scam.
Thayyeb salim
@Thayyebsalim
Aug 10 2017 11:56 UTC
https://codepen.io/Thayyeb_Itachi/pen/rzxKPg
How do I handle the live status properly
append adds it a bit off to the right instead of down under
heroiczero
@heroiczero
Aug 10 2017 12:00 UTC
@Thayyebsalim first do you want to make it under the div. You need to design it that way. You can try using CSS grid maybe or try using float and clear or try using flex
Thayyeb salim
@Thayyebsalim
Aug 10 2017 12:09 UTC
but the thing is that if I remove the anchor tag everything goes into place
@heroiczero
I need a kind of look like that
image.png
SampathKumar27896
@SampathKumar27896
Aug 10 2017 12:14 UTC
Hello everyone ! .Does any one know how to write java script code from scratch for the extension "Allow control allow access" (CORS) that we normally include on browsers ?.
heroiczero
@heroiczero
Aug 10 2017 12:19 UTC
Blauelf
@Blauelf
Aug 10 2017 12:20 UTC
@forkerino I like that list. If it's a puppy and not a unicorn dying on building a To-Do app, one should build something else. Not because of the puppies, but because of the unicorns.
SampathKumar27896
@SampathKumar27896
Aug 10 2017 12:26 UTC
@heroiczero Thank you so much for your help.
CamperBot
@camperbot
Aug 10 2017 12:26 UTC
sampathkumar27896 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1594 | @heroiczero |http://www.freecodecamp.com/heroiczero
Ene Catalin
@EneCatalin
Aug 10 2017 12:27 UTC
any trick to turn a normal number into timer format ?
like 0001 to 00:01 ?
AND still actually have it be seen as 1
Bartosz
@CataciD
Aug 10 2017 12:31 UTC
depends on what you would want to do with it
as in how to use it later on
in general maybe a conversion function?
Blauelf
@Blauelf
Aug 10 2017 12:31 UTC
@EneCatalin Do the conversion for the presentation only, but store the original number.
heroiczero
@heroiczero
Aug 10 2017 12:32 UTC
@Thayyebsalim why are you only making the image and name the link why not make the whole box a link.
WAINGOR
@WAINGOR
Aug 10 2017 12:41 UTC

Hi all, I have a question abt regex:
if I have this string:

var X = "\n                            van Woudenberg\n                                "

how do I get rid of the ghastly whitespace and newline 8*(

cant seem to target it
Bartosz
@CataciD
Aug 10 2017 12:46 UTC
S+ ?
heroiczero
@heroiczero
Aug 10 2017 12:46 UTC
@WAINGOR maybe use replace with regexp
Ene Catalin
@EneCatalin
Aug 10 2017 12:47 UTC
@Blauelf great idea, thanks
CamperBot
@camperbot
Aug 10 2017 12:47 UTC
enecatalin sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4558 | @blauelf |http://www.freecodecamp.com/blauelf
Ene Catalin
@EneCatalin
Aug 10 2017 12:47 UTC
quite amazed I didn't think about it :|
@CataciD you look like skallagrim :D
Bartosz
@CataciD
Aug 10 2017 12:49 UTC
thanks
dunno who that is but ill treat is as a compliment
Ene Catalin
@EneCatalin
Aug 10 2017 12:49 UTC
a youtuber
Bartosz
@CataciD
Aug 10 2017 12:49 UTC
i dont usually do youtubers
most content is shit
i only watch related things :^0
Markus Kiili
@Masd925
Aug 10 2017 12:50 UTC
@EneCatalin Me too. Tell me that my nose is pretty.
Ene Catalin
@EneCatalin
Aug 10 2017 12:50 UTC
I don't dig noses
Blauelf
@Blauelf
Aug 10 2017 12:50 UTC
And I thought you meant Skalla-Grímr...
Bartosz
@CataciD
Aug 10 2017 12:50 UTC
same shit
in short
"wow u look like that viking dude"
pretty standard
Ene Catalin
@EneCatalin
Aug 10 2017 12:51 UTC
^
Bartosz
@CataciD
Aug 10 2017 12:51 UTC
heard that about as many time as a girl hearl "GRIL?!" in a online voip room while playing a game
times*
WAINGOR
@WAINGOR
Aug 10 2017 12:53 UTC

@heroiczero
I tried

var X = "\n                            van Woudenberg\n                                ";
var Y = X.replace(/^[^\n ]*$/,"");
undefined
console.log(Y);
VM5110:1 
                            van Woudenberg

Got this regex from https://stackoverflow.com/questions/23235200/how-to-matches-anything-except-space-and-new-line
but it only leaves out the newline character and keeps the whitespaces... It's pissing me off.

even worse, it doesnt do anything... When I log X === Y it gives true
dafuqqqqq
WAINGOR
@WAINGOR
Aug 10 2017 12:59 UTC
@Blauelf @everyone is there any way to see your "history" of mentions? looking for advice that blauelf gave me but cant find it...
teevik
@teevik
Aug 10 2017 13:01 UTC
You can search
Blauelf
@Blauelf
Aug 10 2017 13:17 UTC
@WAINGOR There's an archive and a search, but not sure how to search for mentions. Do you mean something like the /\S+/g I mentioned maybe yesterday (which would match the two words individually)?
@WAINGOR If you want everything but leading and trailing whitespace, consider using trim (like var Y = X.trim();)
WAINGOR
@WAINGOR
Aug 10 2017 13:19 UTC
thanks @Blauelf , awesome as always <3
CamperBot
@camperbot
Aug 10 2017 13:19 UTC
waingor sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4559 | @blauelf |http://www.freecodecamp.com/blauelf
Guderian Raborg
@hypercuber
Aug 10 2017 14:53 UTC
I want each square to move when you click on it . Can someone help me/ give me tips?
https://codepen.io/hypercuber/pen/oewYRW?editors=0010
prakash chandra yadav
@prakashyadav008
Aug 10 2017 15:09 UTC
@sjames1958gm fcc weather api
codeolas
@codeolas
Aug 10 2017 15:10 UTC
var cid = 
[["PENNY", 1.01],
["NICKEL", 2.05],
["DIME", 3.10],
["QUARTER", 4.25],
["ONE", 90.00],
["FIVE", 55.00],
["TEN", 20.00],
["TWENTY", 60.00],
["ONE HUNDRED", 100.00]];


var sum = 0;

cid.map(function(arr){
    sum += arr[1];
    return sum;
  })
console.log(sum);

Hey guys! I have this sum function. It works, but the result is this decimal number: 3.05999999...

[ 1.01,
  3.0599999999999996,
  6.16,
  10.41,
  100.41,
  155.41,
  175.41,
  235.41,
  335.40999999999997 ]

As you can see, adding 1.01 to 2.05 is equal to 3.0599999... Why is that happening, and how can I avoid it?
```

Brandon Achu
@bachu-dev
Aug 10 2017 15:11 UTC
can someone help me out with a minor rails issue?
Jefferson
@jeffersonnnn
Aug 10 2017 15:12 UTC
hi guys, can i get someone look at my code and tell me where i have it wrong. This is from the Mutation bonfire.

function mutation(arr) {
  var tmp = arr.join("~").toLowerCase();
  var lCArray = tmp.split("~");
  for (var i = 0; i < arr[1].length; i++) {
    var toExecute = 0; 
    if (arr.indexOf(arr[i]) === -1) {
    return false;
  } else {
      return true;
    }
  }

}

mutation(["hello", "hey"]);
Blauelf
@Blauelf
Aug 10 2017 15:13 UTC
@codeolas I first translated into cents by multiplying with 100 and rounding, then operated on integers only (which don't have rounding errors as long as you stay below 2532^{53}), and then divided by 100 again only when returning.
Jason Luboff
@JLuboff
Aug 10 2017 15:13 UTC
@jeffersonnnn You should be checking if each letter for arr[1] is within arr[0] And you also don't want to return true until you're outside your loop
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:16 UTC
@JLuboff Is the clone() any good
Jason Luboff
@JLuboff
Aug 10 2017 15:16 UTC
@Thayyebsalim I've never used it
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:16 UTC
I'm getting inconsistencies while loading
:worried:
almost finished the project
now I may have to restructure it
codeolas
@codeolas
Aug 10 2017 15:19 UTC
@Blauelf That's an idea... Thanks!
CamperBot
@camperbot
Aug 10 2017 15:19 UTC
codeolas sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4560 | @blauelf |http://www.freecodecamp.com/blauelf
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:29 UTC
Is there a way to align divs in the center without using flex
I'm messing up the offline and online section
Can I get some help?
Moisés Man
@moigithub
Aug 10 2017 15:34 UTC
set width n margins ?
Stephen James
@sjames1958gm
Aug 10 2017 15:35 UTC
@Thayyebsalim You can use flex-wrap:wrap; in your offline section
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:36 UTC
isn't that the default
Stephen James
@sjames1958gm
Aug 10 2017 15:37 UTC
@Thayyebsalim You need class="row" for offline and online (which gives you flex-wrap:wrap - which is why streamers works but offline doesn't)
@Thayyebsalim Sweet looking !
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:39 UTC
Thanks @sjames1958gm
CamperBot
@camperbot
Aug 10 2017 15:39 UTC
thayyebsalim sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Aug 10 2017 15:39 UTC
@Thayyebsalim When you inspect streamers - you can see that flex-wrap:wrap comes from grid.scss row class
CamperBot
@camperbot
Aug 10 2017 15:39 UTC
:star2: 8286 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:39 UTC
Man What are you?
superman?
you have too many cookies <3
the class="row" was a fluke I forgot to delete it after a failed attemp at bootstrap @sjames1958gm
Stephen James
@sjames1958gm
Aug 10 2017 15:41 UTC
@Thayyebsalim lol
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:41 UTC
:D
Kelechi Chinaka
@ke1echi
Aug 10 2017 15:55 UTC
function bald(str) {
  var count = 0, array = [], str = str.split('');
  for (var i = 0; i <= str.length; i++) {
    if (str[i] === '/') {
      count++;
      str[i] = str[i].replace(/[/]/,'-');
      array.push(str[i]);
    }
    if (str[i] === '-') {
      count++;
      array.push(str[i]);
    }
  }
  (count === 0) ?  array.push("Clean!") : (count === 1) ?  array.push("Unicorn!") : (count === 2) ? array.push("Homer!") : 
  (count >2 && count <6) ? array.push( "Careless!") : "Hobo";
  return array
}
what am i doing wrong, the tenary is not pushing the strings
Ghulam Shabir
@ghulamshabir
Aug 10 2017 15:59 UTC
@kelechy I think you can not nest ternary operator, use if else instead
Christopher McCormack
@cmccormack
Aug 10 2017 16:07 UTC
you can nest but this is not quite accurate
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:07 UTC
same result, i just cant point where am making that logical mistake @ghulamshabir
Christopher McCormack
@cmccormack
Aug 10 2017 16:07 UTC

for example:

(count >2 && count <6) ? array.push( "Careless!") : "Hobo";

should be

array.push( (count >2 && count <6) ? "Careless!" : "Hobo" )
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:07 UTC
the nesting looks clean to me
Christopher McCormack
@cmccormack
Aug 10 2017 16:07 UTC
I think, let me check
Stephen James
@sjames1958gm
Aug 10 2017 16:09 UTC
@kelechy Why are you not pushing "Hobo"
@kelechy What is this supposed to be doing? counting - and / and replacing / with - and adding a string based on count?
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:12 UTC
the logic was if the condition are met the Hobo is the else conditon @sjames1958gm
Stephen James
@sjames1958gm
Aug 10 2017 16:12 UTC
@kelechy But every other condition you push
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:12 UTC

are not met

yes counting and replace
Blauelf
@Blauelf
Aug 10 2017 16:14 UTC
Very odd, especially what you count. You count each - once, and each / twice, and push the same number of -
Stephen James
@sjames1958gm
Aug 10 2017 16:14 UTC
@kelechy str[i] = str[i].replace(/[/]/,'-'); it's only one letter just str[i] = '-';
@kelechy The pushes work for all but Hobo
array.push( "Careless!") : array.push("Hobo");
Ananda Johnson
@Sovember
Aug 10 2017 16:17 UTC
Hi guys. Still havne't figured this out, I have a question about the Javascript "Weather App Challenge" basically I'm trying to use Jquery to access a JSON "location identifier" but I keep getting this message in the console when I try to log the object : "he 'Access-Control-Allow-Origin' header contains multiple values 'https://s.codepen.io, *', but only one is allowed." Any idea what's happening and what I can do to remedy this? Thanks for any insight!!
Christopher McCormack
@cmccormack
Aug 10 2017 16:17 UTC
@Sovember which API?
Ananda Johnson
@Sovember
Aug 10 2017 16:18 UTC
the one that they gave in the challenge "open weather api"
Blauelf
@Blauelf
Aug 10 2017 16:18 UTC
I'd prefer a single push, like
    array.push(count === 0 ? "Clean!" : count === 1 ? "Unicorn!" : count === 2 ? "Homer!" : count > 2 && count < 6 ? "Careless!" : "Hobo");
Ananda Johnson
@Sovember
Aug 10 2017 16:18 UTC
@cmccormack
Christopher McCormack
@cmccormack
Aug 10 2017 16:18 UTC
@Blauelf agreed
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:19 UTC
the count was wrongly done, increment count when '-' was met
Christopher McCormack
@cmccormack
Aug 10 2017 16:19 UTC
@Sovember https://fcc-weather-api.glitch.me?
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:19 UTC
nice @Blauelf
@sjames1958gm i will fix now
Ananda Johnson
@Sovember
Aug 10 2017 16:20 UTC
Awesome thanks I'm gonna try this! @cmccormack
CamperBot
@camperbot
Aug 10 2017 16:20 UTC
:star2: 1118 | @cmccormack |http://www.freecodecamp.com/cmccormack
sovember sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Aug 10 2017 16:20 UTC
@Sovember np
Stephen James
@sjames1958gm
Aug 10 2017 16:33 UTC
@kelechy Did you get it?
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:40 UTC
i fixed the part @Blauelf talk about
@sjames1958gm
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:45 UTC
just trying to re-arrange the logic @sjames1958gm
Kelechi Chinaka
@ke1echi
Aug 10 2017 17:03 UTC
function bald(str) {
  var count = 0, array = [], str = str.split('');
  for (var i = 0; i < str.length; i++) {
    if (str[i] === '/') {
      count++;
      str[i] = str[i].replace(/[/]/,'-');
    }
  }  
    array.push(count === 0 ? "Clean!" : count === 1 ? "Unicorn!" : count === 2 ? "Homer!" : count > 2 && count < 6 ? "Careless!" : "Hobo");
    return str.join('') + ' ' + array.join('')
}
Expected: '[\'----------\', \'Unicorn!\']'
how do i fix that return line to get the expeted result
tried using ... but to no avail
Gustavo Azevedo
@gustavoaz7
Aug 10 2017 17:10 UTC
@kelechy What is your input ?
Kelechi Chinaka
@ke1echi
Aug 10 2017 17:16 UTC
sori, nvm
soulproprietor
@soulproprietor
Aug 10 2017 17:16 UTC
how do yu attatch an image?
to this chat
Jason Luboff
@JLuboff
Aug 10 2017 17:17 UTC
@soulproprietor Copy and paste it for an image. But to format code you would do
```
shift+enter for new line, paste code, shift+enter for new line
```
soulproprietor
@soulproprietor
Aug 10 2017 17:18 UTC
thanks
$.getJSON(apiURL, function(data) {
       var tempCels = data.main.temp;
       var tempFar = tempCels * (9 / 5) + 32;
        $("#cityTitle").html(data.name);
        $("#temp").html(data.main.temp);
        $("#temp2").html(
          "<img src='" + data.weather[0].icon + "' alt='weatherLogo'>"
        );
        $("switch").on("click", function(){

        $('temp').html(temp)
      });
how can I use these variables outside this getJSON call?
I want to be able to call the temperature or the city name later
Stephen James
@sjames1958gm
Aug 10 2017 17:20 UTC
@soulproprietor Declare them outside the getJSON callback.
Realize you cannot use the data until the callback has run.
But if you display the data from the callback, then allow the user to do something then they should be available.
Kelechi Chinaka
@ke1echi
Aug 10 2017 17:21 UTC
fixed @sjames1958gm
Stephen James
@sjames1958gm
Aug 10 2017 17:21 UTC
@kelechy :+1:
soulproprietor
@soulproprietor
Aug 10 2017 17:23 UTC
 var tempCels = data.main.temp;
      $.getJSON(apiURL, function(data) {
       //var tempCels = data.main.temp;
       var tempFar = tempCels * (9 / 5) + 32;
        $("#cityTitle").html(data.name);
    // $("#temp").html(data.main.temp);
        $("#temp2").html(
          "<img src='" + data.weather[0].icon + "' alt='weatherLogo'>"
        );
        $("switch").on("click", function(){

        $('temp').html(temp)
      });
$('temp').html(data.main.temp);
would this work? @sjames1958gm
Roxroy
@roxroy
Aug 10 2017 17:27 UTC
@soulproprietor , you should cast tempCels to integer using the parseInt() function when calculating tempFar.
soulproprietor
@soulproprietor
Aug 10 2017 17:27 UTC
ya... ignore that part. I should have taken it out.
right now I just want to know how to use a variable that I used with the getJSON call in other functions
like I use getJSON to get the temperature, then how do I use it later in the script?
I would have to do a function that returns the value that I want to use later? so it would return a variable 'city' for example, then I could use that later?
Robert Marić
@Mariciano95
Aug 10 2017 17:29 UTC
Maybe this is not the right place for this, but does anyone know React-Native so I can PM about something?
Stephen James
@sjames1958gm
Aug 10 2017 17:31 UTC
@soulproprietor no. you have to set the value inside the callback

@soulproprietor
before the getJSON

var tempCels;
var tempFar;

inside the getJSON

 tempCels = data.main.temp;
tempFar = tempCels * (9 / 5) + 32;
@soulproprietor Inside the getJSON put the values into the HTML for the initial user rendering,
Then if you have a click handler it can access the two values later on user interaction
soulproprietor
@soulproprietor
Aug 10 2017 17:36 UTC
ah ok. cool i'll work with that. thank you!
Stephen James
@sjames1958gm
Aug 10 2017 17:50 UTC
@soulproprietor :+1:
soulproprietor
@soulproprietor
Aug 10 2017 18:06 UTC
{
"batchcomplete": "",
"query": {
"pages": {
"15580374": {
"pageid": 15580374,
"ns": 0,
"title": "Main Page",
how can I reference the pageid? when I try to reference the property "15580374", I receive an error saying "unexpected number"
like the property name shouldnt be a number or something
Gulsvi
@gulsvi
Aug 10 2017 18:08 UTC
@soulproprietor add &formatversion=2 to your URL
soulproprietor
@soulproprietor
Aug 10 2017 18:08 UTC
$(document).ready(function() {
var url = "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json";

$.getJSON(url, function(data){
  $('#output').html(data.query.pages.["15580374"]);
}); 
  });
ok @SkyC0der
does it matter where in the URL it goes?
Gulsvi
@gulsvi
Aug 10 2017 18:10 UTC
No, it doesn't matter
This returns all the pages with title "Main Page"
"https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json&formatversion=2&origin=*"
soulproprietor
@soulproprietor
Aug 10 2017 18:12 UTC
ok so I notice that changed the pageid property name to "pageid"
so is this a common error? property names shouldn't be numbers?
Gulsvi
@gulsvi
Aug 10 2017 18:13 UTC
@soulproprietor No, not an error at all, just a different format for the output that may make it easier to loop through
soulproprietor
@soulproprietor
Aug 10 2017 18:14 UTC
how could I refernce this without changing the url then?
Gulsvi
@gulsvi
Aug 10 2017 18:14 UTC
A for...in loop works great for this regardless of the formatversion, but that isn't something they teach us at FCC
  var url = "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json&origin=*";
  $.getJSON(url, function(data) {
    for (var page in data.query.pages) {
      console.log(data.query.pages[page].title);
    }
  });
You could also use Object.keys()
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:16 UTC
thanks @SkyC0der
CamperBot
@camperbot
Aug 10 2017 18:16 UTC
thayyebsalim sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2356 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Aug 10 2017 18:16 UTC
You're welcome :sparkles:
soulproprietor
@soulproprietor
Aug 10 2017 18:19 UTC
thank you
Chris Dalton
@manwithgills
Aug 10 2017 18:22 UTC
Need some help testing my weather app. Can anyone outside the US or Liberia tell me if it displays weather data in C? https://codepen.io/manwithgills/full/WEoKqz
Ene Catalin
@EneCatalin
Aug 10 2017 18:23 UTC
found my location
but gives no temperature
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:23 UTC
@manwithgills No it doesn't
Chris Dalton
@manwithgills
Aug 10 2017 18:24 UTC
@EneCatalin What is your location?
Ene Catalin
@EneCatalin
Aug 10 2017 18:24 UTC
@RoniqueRicketts does not give the temp, just the location ?
Romania
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:24 UTC
@EneCatalin Sorry It is not working and I am in Jamaica
Chris Dalton
@manwithgills
Aug 10 2017 18:25 UTC
@RoniqueRicketts ok. So it shows your country but does not append the weather data.
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:25 UTC
@EneCatalin Its only showing in Fahrenheit I am in Jamaica
Ene Catalin
@EneCatalin
Aug 10 2017 18:26 UTC
image.png
Chris Dalton
@manwithgills
Aug 10 2017 18:26 UTC
@EneCatalin Thank you
CamperBot
@camperbot
Aug 10 2017 18:26 UTC
manwithgills sends brownie points to @enecatalin :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @enecatalin |http://www.freecodecamp.com/enecatalin
Chris Dalton
@manwithgills
Aug 10 2017 18:27 UTC
@RoniqueRicketts Can you screenshot it for me?
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:28 UTC
Weather.PNG
@manwithgills there u go
Ene Catalin
@EneCatalin
Aug 10 2017 18:28 UTC
@manwithgills np,take your time, this is one of the more enjoyable projects in my experience
Chris Dalton
@manwithgills
Aug 10 2017 18:29 UTC
thanks. Is it really that cool there? Its hot here in Orlando FL.
Ene Catalin
@EneCatalin
Aug 10 2017 18:30 UTC
tried it in firefox too, same result as before
Chris Dalton
@manwithgills
Aug 10 2017 18:30 UTC
@EneCatalin I have been working on this thing for a while. I am having issues with the toggle switching the data.
Ene Catalin
@EneCatalin
Aug 10 2017 18:30 UTC
@manwithgills also consider this https://openweathermap.org/api
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:31 UTC
Weather.PNG
@manwithgills no its not
I too have some issues with my Tic-tac-toe game. I am stuck
Ene Catalin
@EneCatalin
Aug 10 2017 18:32 UTC
an actual dev stuck on that, wow
ostrich is rekt
Chris Dalton
@manwithgills
Aug 10 2017 18:32 UTC
@RoniqueRicketts I thought it strange. Thanks. @EneCatalin I started with that API but I think I had issues with it due to the SSL.
CamperBot
@camperbot
Aug 10 2017 18:32 UTC
:warning: manwithgills already gave enecatalin points
:cookie: 351 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
manwithgills sends brownie points to @roniquericketts and @enecatalin :sparkles: :thumbsup: :sparkles:
Ene Catalin
@EneCatalin
Aug 10 2017 18:33 UTC
@manwithgills huh ? Never ran into an issue, weird
I loved their docs
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:33 UTC
@EneCatalin Yes I am stuck on tic-tac-toe. https://codepen.io/Ronique/pen/EXMRNB
Diego Mayer
@Chrono79
Aug 10 2017 18:33 UTC
@EneCatalin it didn't support https before
Ene Catalin
@EneCatalin
Aug 10 2017 18:34 UTC
I am still at the pomodoro, did about half
Ronique Ricketts
@RoniqueRicketts
Aug 10 2017 18:34 UTC
@manwithgills your welcome man.
Chris Dalton
@manwithgills
Aug 10 2017 18:34 UTC
@EneCatalin I may play with it again if they have changed it to support https. Well its back to work. Have a good one.
Ene Catalin
@EneCatalin
Aug 10 2017 18:34 UTC
gl
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:35 UTC
@manwithgills location is ok but no info
Chris Dalton
@manwithgills
Aug 10 2017 18:35 UTC
@Thayyebsalim Thank you
CamperBot
@camperbot
Aug 10 2017 18:35 UTC
manwithgills sends brownie points to @thayyebsalim :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @thayyebsalim |http://www.freecodecamp.com/thayyebsalim
Diego Mayer
@Chrono79
Aug 10 2017 18:36 UTC
@manwithgills what's the checkbox for? Switching units?
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:36 UTC
Yeah
he is looking to turn it into a button in the future possibly
Meanwhile I have no idea what do do on my project
https://s.codepen.io/Thayyeb_Itachi/debug/rzxKPg/GnMnbVmdnzDM
Diego Mayer
@Chrono79
Aug 10 2017 18:37 UTC
I couldn't get the temp data either, only the location in his page
Gulsvi
@gulsvi
Aug 10 2017 18:39 UTC

@manwithgills A great way to test different locations is to manually enter latitude and longitude in place of your position.coords.latitude/longitude:

    latitude = position.coords.latitude;
    longitude = position.coords.longitude;

https://www.infoplease.com/world/world-geography/major-cities-latitude-longitude-and-corresponding-time-zones

Diego Mayer
@Chrono79
Aug 10 2017 18:39 UTC
@Thayyebsalim Looks pretty nice, the only thing that seems weird is how you fill the background
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:40 UTC
the background image?
Diego Mayer
@Chrono79
Aug 10 2017 18:40 UTC
yes
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:40 UTC
should I change it into a gradient or something?
@Chrono79 Thanks for the input
CamperBot
@camperbot
Aug 10 2017 18:41 UTC
thayyebsalim sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4516 | @chrono79 |http://www.freecodecamp.com/chrono79
Nathan Vu
@NathanVu
Aug 10 2017 18:43 UTC
Is anyone one Make Object Properties Private section for freecodecamp javascript? I'm stuck
Diego Mayer
@Chrono79
Aug 10 2017 18:47 UTC
@Thayyebsalim It seems weird to me, maybe others or you like it like it is. There are some options like repeating the background so it doesn't seem to resize when the content changes, but the current imagen has some gradient and repeating it maybe is not the best way of solving it. I'm just been too picky maybe.
@NathanVu show your code
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:50 UTC
I'll change it
soulproprietor
@soulproprietor
Aug 10 2017 18:50 UTC
i'm stumped: why would this call work with one of these URLs but not with the other? the data seems to be structured the same way:
$(document).ready(function() {
//var url = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=tiger&formatversion=2"

  var url = "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json&formatversion=2&origin=*"

$.getJSON(url, function(data){
  $('#output').html(data.query.pages[0].pageid);
}); 
  });
Nathan Vu
@NathanVu
Aug 10 2017 18:50 UTC
'''s
CamperBot
@camperbot
Aug 10 2017 18:50 UTC
:bulb: to format code use backticks! ``` more info
Thayyeb salim
@Thayyebsalim
Aug 10 2017 18:50 UTC
btw is there any other way to link fonts other than google fonts?
CamperBot
@camperbot
Aug 10 2017 18:51 UTC
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Aug 10 2017 18:52 UTC
@soulproprietor which one is the one that works?
the second one has the origin=* param that I can't see in the first one
Nathan Vu
@NathanVu
Aug 10 2017 18:54 UTC
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.


};

var myCar = new Car();

var myBike = new Bike();
@Chrono79 I don't understand what is happening in this code?
Diego Mayer
@Chrono79
Aug 10 2017 18:55 UTC
@NathanVu you have to create a constructor similar to the one that's already there (the Car one)
Nathan Vu
@NathanVu
Aug 10 2017 18:55 UTC
instruction says Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
soulproprietor
@soulproprietor
Aug 10 2017 18:56 UTC
@Chrono79 the origin=* one works
the other one is there but you have to scroll to the right
@Chrono79 the format is the same, copy and paste into browser to confirm
Diego Mayer
@Chrono79
Aug 10 2017 18:58 UTC
accelerate and decelerate are public methods of Car constructor and speed is a private property there @NathanVu
var url = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=tiger&formatversion=2"
I don't see it there, and pasting it in the browser is no the same as requesting it via ajax from another site
Anthony Armfield
@Anthony-Armfield
Aug 10 2017 18:59 UTC
I have a script to find the lowest number that is evenly divisible by all numbers between 1 and 10, but it doesn't seem to be working, any advice? https://codepen.io/aarmfield/pen/KvNYzG?editors=0010
Nathan Vu
@NathanVu
Aug 10 2017 19:01 UTC
@Chrono79 I'm just confused what exactly is gear? Am I suppose to set a value for it?
Diego Mayer
@Chrono79
Aug 10 2017 19:01 UTC
@Anthony-Armfield "[CodePen]: An infinite loop (or a loop taking too long) was detected, so we stopped its execution. Sorry!"
@NathanVu gear for Bike is like speed for Car, it's a private property, you won't access it directly from outside, you'll have to use some public methods to set/change its value
Anthony Armfield
@Anthony-Armfield
Aug 10 2017 19:02 UTC
@Chrono79 I guess I don't understand where the infinite loop is. My while loop has both a false and a true...
Diego Mayer
@Chrono79
Aug 10 2017 19:04 UTC
@Anthony-Armfield your for loop never runs
soulproprietor
@soulproprietor
Aug 10 2017 19:04 UTC
@Chrono79 but the api url is good, if you put it in the browser, you see that it links to json data. so I dont think I understand your question
Diego Mayer
@Chrono79
Aug 10 2017 19:04 UTC
@soulproprietor do you have that code in a codepen?
Anthony Armfield
@Anthony-Armfield
Aug 10 2017 19:05 UTC
@Chrono79 It runs. The console even displays the array (though it is incorrect) that is created from it.
Diego Mayer
@Chrono79
Aug 10 2017 19:05 UTC

@Anthony-Armfield

function getDivNumArray(numInput) {
    for (let i = 0; i <= numInput; i++) {
        return divNum.push(i);
    }
}

this function returns a number, not an array

returning inside a loop like that exits the loop and push returns a number
Anthony Armfield
@Anthony-Armfield
Aug 10 2017 19:06 UTC
@Chrono79 it pushes the number to the array, should I not use a return?
Diego Mayer
@Chrono79
Aug 10 2017 19:07 UTC
@Anthony-Armfield you should return the array after the loop
I tried to change but a monochrome bg looks bland
I'm confused
Stephen James
@sjames1958gm
Aug 10 2017 19:08 UTC
@Anthony-Armfield Also, probably not a good idea to push 0 to your divisor array?
Thayyeb salim
@Thayyebsalim
Aug 10 2017 19:08 UTC
should I keep working on this one or move on?
Anthony Armfield
@Anthony-Armfield
Aug 10 2017 19:09 UTC
@sjames1958gm Yes, good point. Thanks.
CamperBot
@camperbot
Aug 10 2017 19:09 UTC
anthony-armfield sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8287 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Aug 10 2017 19:11 UTC
@soulproprietor try adding &origin=* at the end of the first one
Anthony Armfield
@Anthony-Armfield
Aug 10 2017 19:11 UTC
I still can't get the script out of an infinite loop @Chrono79 any other ideas?
soulproprietor
@soulproprietor
Aug 10 2017 19:11 UTC
ok
Diego Mayer
@Chrono79
Aug 10 2017 19:11 UTC
@Anthony-Armfield
function getDivNumArray(numInput) {
    for (let i = 1; i <= numInput; i++) {
        divNum.push(i);
    }
  return divNum;
}
Stephen James
@sjames1958gm
Aug 10 2017 19:12 UTC
@Thayyebsalim I say move on.
Diego Mayer
@Chrono79
Aug 10 2017 19:12 UTC
Do you have it like that?
soulproprietor
@soulproprietor
Aug 10 2017 19:12 UTC
wow, it worked... i'll have to read up about that but I don't understand why it needs that
thanks @Chrono79
CamperBot
@camperbot
Aug 10 2017 19:12 UTC
soulproprietor sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4517 | @chrono79 |http://www.freecodecamp.com/chrono79
Thayyeb salim
@Thayyebsalim
Aug 10 2017 19:12 UTC
thanks @sjames1958gm
My confusion is whether it is good enough