These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Aug 2017
Bradley Sands
@sandsbe
Aug 10 2017 00:00
Ok, but neither setTimeoutor setInterval are standard method/functions in JS. So...?
Jim Tryon
@jimtryon
Aug 10 2017 00:01
They are JS functions.
Jim Tryon
@jimtryon
Aug 10 2017 00:03
You seem to be looking at a different documentation
Bradley Sands
@sandsbe
Aug 10 2017 00:04
@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
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
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
@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
@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
derp
yeah that was it, gotta be more perceptive. Thanks @khaduch & @sjames1958gm
CamperBot
@camperbot
Aug 10 2017 01:39
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
@insouciantone - that will fix it - you get your JSON dumped into the DOM
Stephen James
@sjames1958gm
Aug 10 2017 01:39
It is almost instinctive for me to open the console
insouciantone
@insouciantone
Aug 10 2017 01:40
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
@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
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
@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
@insouciantone :+1:
juni
@junipberry
Aug 10 2017 01:55

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
@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
Just got through the basic Javascript!
Pete Givens
@petegivens
Aug 10 2017 02:18
@addisonday congrats
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:18
@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
lol, I was wondering what you mean by e.g.
Addison
@addisonday
Aug 10 2017 02:19
@petegivens Thank you!
CamperBot
@camperbot
Aug 10 2017 02:19
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
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
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
@petegivens not sure but try adding function to it: setTimeout(function(){ alert('hey')},5000)
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:23

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

i = ??

@GingerChew
Ginger
@GingerChew
Aug 10 2017 02:24
@kumquatfelafel yep, that would do it, thanks m8
CamperBot
@camperbot
Aug 10 2017 02:24
gingerchew sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 589 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:24
@GingerChew can't guarantee that's everything, but in particular stuck out. ;)
Pete Givens
@petegivens
Aug 10 2017 02:25
@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
petegivens sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1638 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Ginger
@GingerChew
Aug 10 2017 02:25
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
@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
@Marmiz thank you
CamperBot
@camperbot
Aug 10 2017 02:26
petegivens sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1015 | @marmiz |http://www.freecodecamp.com/marmiz
kumquatfelafel
@kumquatfelafel
Aug 10 2017 02:33
@EgnaroDev family secret! :o
LovingVi
@LovingVi
Aug 10 2017 02:36
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

@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
var code = "formatted";
CallMeOrange
@EgnaroDev
Aug 10 2017 02:48
@LovingVi
Margaret
@Margaret2
Aug 10 2017 02:48
@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
```js
code
```
to
code
LovingVi
@LovingVi
Aug 10 2017 02:48
OK
LovingVi
@LovingVi
Aug 10 2017 02:55
@EgnaroDev Sorry I'm a newcomer and don't know how to use these methods。
@Margaret2 TKS
Ginger
@GingerChew
Aug 10 2017 02:58
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
I think ?callback=? is always at the end, not sure...
Long Nguyen
@longnt80
Aug 10 2017 02:59
@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
@longnt80 okay, I was confused how that endpoint was supposed to work
@longnt80 thanks m8
CamperBot
@camperbot
Aug 10 2017 03:00
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
@GingerChew yeah the instruction for that project is confusing
I meant the API
Ginger
@GingerChew
Aug 10 2017 03:15
Am I supposed to hard code each json request for each listed user?
leetboy
@leetboy
Aug 10 2017 03:21
tg
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:22
What does the this mean guys??
return str.slice(0, num > 3 ? num - 3 : num) + '...';
Long Nguyen
@longnt80
Aug 10 2017 03:23
@ma5one1 you meant this part num > 3 ? num - 3 : num?
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:23
exaclty
Long Nguyen
@longnt80
Aug 10 2017 03:23
that is equivalent to:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:23
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
yeah this :point_up: August 10, 2017 10:23 AM
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:24
I'll leave more generalized explanation to @longnt80
err... :laughing:
Long Nguyen
@longnt80
Aug 10 2017 03:24
: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
whats this :3
o yeah
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:26
ternary.
Long Nguyen
@longnt80
Aug 10 2017 03:26
I can't remember that word
Maximino V. Jardin III
@ma5one1
Aug 10 2017 03:27
got it..now i got to remember it round of brownie
:clap:
@longnt80 thank you
CamperBot
@camperbot
Aug 10 2017 03:28
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
@kumquatfelafel thank you
CamperBot
@camperbot
Aug 10 2017 03:28
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
@ma5one1 :smile:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:30

@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
@kumquatfelafel so it has two conditions in one line resulting either a true or false outcome
Addison
@addisonday
Aug 10 2017 03:33
What is a delimeter in Javascript?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 03:33
@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
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
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
@GingerChew make an array of all user names and loop through it, call the API for each
Ginger
@GingerChew
Aug 10 2017 03:47
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
what warned you? codepen?
Ginger
@GingerChew
Aug 10 2017 03:54
@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
@GingerChew I don't see any warning
Ginger
@GingerChew
Aug 10 2017 03:57
if you analyze the js it pops up
Long Nguyen
@longnt80
Aug 10 2017 03:59
with the dev tool?
Ginger
@GingerChew
Aug 10 2017 04:02
no in the javascript window, theres the chevron with some options there, its in that window
Long Nguyen
@longnt80
Aug 10 2017 04:04
@GingerChew maybe you were editing it, I just found warning about missing syntax
Ginger
@GingerChew
Aug 10 2017 04:07
hmmm, maybe, who knows
it's working either way
slertka
@slertka
Aug 10 2017 04:07
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
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
@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
yeah. $1 represents first capture group ([a-z]), $2 represents second group ([A-Z]).
slertka
@slertka
Aug 10 2017 04:09
@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
yes
slertka
@slertka
Aug 10 2017 04:09
thanks @longnt80 @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 04:09
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
@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

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
@longnt80 not sure I'm following now....
Long Nguyen
@longnt80
Aug 10 2017 04:13
I know, it's hard to explain
slertka
@slertka
Aug 10 2017 04:13
I also have a question since the documentation says this is non-standard
Ginger
@GingerChew
Aug 10 2017 04:13
@longnt80 yep that fixed it and it still works, thanks!
CamperBot
@camperbot
Aug 10 2017 04:13
gingerchew sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 493 | @longnt80 |http://www.freecodecamp.com/longnt80
slertka
@slertka
Aug 10 2017 04:13
What are the other options?
Long Nguyen
@longnt80
Aug 10 2017 04:13
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
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
this chat is active, may I ask a non related question
slertka
@slertka
Aug 10 2017 04:17
that makes sense to me, but dont quite the other quote
*example
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:18

Never!!!! :o

...

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

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

Never!!!! :o

:cry:

slertka
@slertka
Aug 10 2017 04:19
ooohhh i get it
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:19
@slertka are you asking why the \s doesn't get included?
slertka
@slertka
Aug 10 2017 04:19
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
@slertka you got it?
ok
slertka
@slertka
Aug 10 2017 04:20
yeah!
thanks @longnt80
CamperBot
@camperbot
Aug 10 2017 04:20
slertka sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: slertka already gave longnt80 points
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:20
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
@Giveback007 depends on your goal
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:21
my goal is to get a job
Greg Duncan
@GregatGit
Aug 10 2017 04:21
@Giveback007 have you used create react app for you projects?
@Giveback007 or webpack?
Long Nguyen
@longnt80
Aug 10 2017 04:22
then I guess just learn the skills the employers are seeking
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:22
@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
@Giveback007 Isn't that everyone's goal.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:23
@revisualize well, some have jobs
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:23
My goal is to get money vicariously through other people's jobs! :o
Greg Duncan
@GregatGit
Aug 10 2017 04:23
@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
@Giveback007 It is 923pm and I'm still at mine.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:24
@GregatGit let's assume I am done with react,
what's better next d3 or node.js
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:24
'tis 12:45am here, and ima go to bed. :p
Greg Duncan
@GregatGit
Aug 10 2017 04:24
@Giveback007 you will have to know node
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:25
@revisualize :fearful:
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:25
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
@ArchivalBoat50 i remember you!!! you said that last time about a month ago :smile:
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:25
Yeah
kumquatfelafel
@kumquatfelafel
Aug 10 2017 04:25
@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
I dont even know anymore
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:26
@revisualize are you devops?
Joseph
@revisualize
Aug 10 2017 04:26
@Giveback007 I'm a Network Systems Administrator III.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:26

@GregatGit

@Giveback007 you will have to know node

that's what I was thinking

ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:26
@Giveback007 Can you help me out?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:27
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
@Giveback007 Why do you ask that?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:27
@revisualize about devops?
Joseph
@revisualize
Aug 10 2017 04:28
@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
@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
I just spent 5 hours struggling with a service upgrade.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:29
I talked to a few dev ops guys so far and 2 of them work nights
Joseph
@revisualize
Aug 10 2017 04:30
I started at 8am.
it's 930pm.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:30
@revisualize (i am so sorry)
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:30
@Giveback007 First of all whats the difference between a getJSON and an AJAX call?
Joseph
@revisualize
Aug 10 2017 04:30
S'sall good.
@ArchivalBoat50 getJSON gets JSON
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:30
@ArchivalBoat50 well that's a multiplayer answer to it
sometimes people say Ajax when they mean JSON
Joseph
@revisualize
Aug 10 2017 04:30
@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
most apis are done with JSON
@revisualize did I misspeak?
Joseph
@revisualize
Aug 10 2017 04:31
I don't think so.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:31
so they're basically just the same function but ajax can do more?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:32
@ArchivalBoat50 all 4 of the projects you will do here will return JSON objects
Joseph
@revisualize
Aug 10 2017 04:32
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
so you can use ajax for other different databases?
Joseph
@revisualize
Aug 10 2017 04:33
@ArchivalBoat50 Or just text.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:33
@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
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
Oh yeah I forgot, what exactly is XML again?
Joseph
@revisualize
Aug 10 2017 04:35
@ArchivalBoat50 Kind of like HTML but different.
LOL
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:35
@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
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
@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
Yeah my other question would be why my program is not logging the data
Joseph
@revisualize
Aug 10 2017 04:37
@Giveback007 You can.
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:37
@revisualize ??? !!!
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:38
@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
giveback007 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4423 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 10 2017 04:41
OMG! Yay! I got 1 brownie point today!
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:41
@Giveback007 Oh why is there a 400?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:42
@ArchivalBoat50 i messed around with your code
and broke it for a sec
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:42
oh
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:42
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
gave me a 403?
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:43
can you take a screen shot?
how do you send an image on gitter?
Long Nguyen
@longnt80
Aug 10 2017 04:46
drag and drop on here
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:46
@ArchivalBoat50 lol you just coppy pasted my code
it was a hint
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:46
windbow403.jpg
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:46
I also had variables in there
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:46
there we go
I didn't do anything
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:47
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
???
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:49
@ArchivalBoat50 looks like you've been away from coding a little bit too long
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:49
oh wait
whats this wind-bow thing
I kind of know what you mean't
Long Nguyen
@longnt80
Aug 10 2017 04:50
@ArchivalBoat50 wind-bow just a url
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:50
@ArchivalBoat50 free code camp has their own api link for helping you
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:51
oh yeahhhh
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:51
@ArchivalBoat50 because twich sometimes switches up the way their api works and messes everyone up
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:52
so i need to change some things
Dovydas Stirpeika
@Giveback007
Aug 10 2017 04:52
@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
@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
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
@Giveback007 Ok thx for your help
CamperBot
@camperbot
Aug 10 2017 04:55
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
@ArchivalBoat50 np
before I go, does anyone have a justification on why I should learn D3 first?
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 04:57
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
@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
@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
@ArchivalBoat50
$.getJSON('https://wind-bow.glitch.me/twitch-api/streams/' + user, function(data){
// do your stuffs
});
Ananda Johnson
@Sovember
Aug 10 2017 05:10
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
@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
@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
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
@taiJones00 often the api provider will give you the instruction
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:23

@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
@ArchivalBoat50 yes
Markus Kiili
@Masd925
Aug 10 2017 05:25
@ArchivalBoat50 Maybe you need to use different url's with those calls?
Use streamers[i] or something.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:26
oh oops i forgot to iterate
How come nothing is being logged?
Markus Kiili
@Masd925
Aug 10 2017 05:29
@ArchivalBoat50 Check for errors on the browser developer tools console.
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:30
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
@ArchivalBoat50 codepen's console doesn't show as much as the browser's console
ArchivalBoat50
@ArchivalBoat50
Aug 10 2017 05:33
The three links, do I put three of those getJSON functions?
Long Nguyen
@longnt80
Aug 10 2017 05:34
@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
@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
@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
Long Nguyen
@longnt80
Aug 10 2017 05:42
@Masd925 thank you
CamperBot
@camperbot
Aug 10 2017 05:42
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
That's the most cookies I've seen
Well done @Masd925
Mohammed Boudad
@matrixersp
Aug 10 2017 07:23
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
@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
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
@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
Okay, Thanks @Masd925
CamperBot
@camperbot
Aug 10 2017 07:27
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
@Masd925 nice
Markus Kiili
@Masd925
Aug 10 2017 07:27
@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
@Masd925 Boolean is too easy
Markus Kiili
@Masd925
Aug 10 2017 07:27
Or you could just return word; from the callback.
Mohammed Boudad
@matrixersp
Aug 10 2017 07:29
Oh! yeh right, thanks again @Masd925
CamperBot
@camperbot
Aug 10 2017 07:29
tekkie7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: tekkie7 already gave masd925 points
Markus Kiili
@Masd925
Aug 10 2017 07:29
@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

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
gm everyone
Bartosz
@CataciD
Aug 10 2017 08:04
woowow gm
anyone needs helps?D:
Ccs99817
@ccs99817
Aug 10 2017 08:05
@CataciD I need
Bartosz
@CataciD
Aug 10 2017 08:05
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
i want to remove an item in the array
Bartosz
@CataciD
Aug 10 2017 08:07
ye i know
wiat i need to check it
Ccs99817
@ccs99817
Aug 10 2017 08:07
then, i guess using splice is better although i do not need to return
Bartosz
@CataciD
Aug 10 2017 08:08
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
harsh
:D
Bartosz
@CataciD
Aug 10 2017 08:08
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
@ccs99817 why not .filter?
Bartosz
@CataciD
Aug 10 2017 08:09
yeah filter is also good
even better
Ccs99817
@ccs99817
Aug 10 2017 08:09
@forkerino i have no idea how to use it lol
Bartosz
@CataciD
Aug 10 2017 08:09
filter is easy
filter goes through all elements
Pieter Stokkink
@forkerino
Aug 10 2017 08:10
@ccs99817 good time to learn!
Bartosz
@CataciD
Aug 10 2017 08:10
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
oic
Bartosz
@CataciD
Aug 10 2017 08:10
is check if the currently checked element is !indexOf(element) of the other table
i think
Ccs99817
@ccs99817
Aug 10 2017 08:11
oh, i think i get it
Bartosz
@CataciD
Aug 10 2017 08:11
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
can i use the filter function twice to ensure nothing is skipped?
Pieter Stokkink
@forkerino
Aug 10 2017 08:13
@ccs99817 if you .concat first, you only have to .filter once.
Bartosz
@CataciD
Aug 10 2017 08:15
with concat you would have to figure out a way
to remove duplicates
Ccs99817
@ccs99817
Aug 10 2017 08:16
how can i find the occurrence of an item in the array?
Pieter Stokkink
@forkerino
Aug 10 2017 08:16
.indexOf, .includes
@CataciD you can still access the original arrays after .concat
Ccs99817
@ccs99817
Aug 10 2017 08:17
Isn't .indexOf is used to find the index of the fist occurrence?
Bartosz
@CataciD
Aug 10 2017 08:17
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
@CataciD @ccs99817 inside .filter, you still need to use .indexOf / .includes
Bartosz
@CataciD
Aug 10 2017 08:18
yes but you use it on an array that has only one occurance
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:19
@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
@CataciD even if you choose the longest one, you might still skip sth
Pieter Stokkink
@forkerino
Aug 10 2017 08:19
you have to check if the element is either NOT in arr1 OR NOT in arr2
Jefferson
@jeffersonnnn
Aug 10 2017 08:19

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
@ccs99817 example?
Pieter Stokkink
@forkerino
Aug 10 2017 08:19
@kumquatfelafel What up kumquat?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:20
@forkerino hey, not much. you?
Bartosz
@CataciD
Aug 10 2017 08:20
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
@kumquatfelafel Have a day off. Need to find a house.
Ccs99817
@ccs99817
Aug 10 2017 08:21
@CataciD What if there is an unique item in the shortest array?
Bartosz
@CataciD
Aug 10 2017 08:21
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
yup
Bartosz
@CataciD
Aug 10 2017 08:22
tho if i remember correctly
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:22
looking for somewhere closer?
Jefferson
@jeffersonnnn
Aug 10 2017 08:22

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
i usually just did it a bit around
i made a new array
concat tho others
Pieter Stokkink
@forkerino
Aug 10 2017 08:22
@kumquatfelafel yeah, around the Hague. In Amsterdam now.
Bartosz
@CataciD
Aug 10 2017 08:22
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
Thank you guys. I think I can handle it now
@CataciD @forkerino
CamperBot
@camperbot
Aug 10 2017 08:24
: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
:+1:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:24
@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
@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
@kumquatfelafel good morning :D
Jefferson
@jeffersonnnn
Aug 10 2017 08:28
@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

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
@longnt80 it's ... slightly pitch black still, but I guess this is good enough haha
WAINGOR
@WAINGOR
Aug 10 2017 08:29
and now it doesnt.. dafuq
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:29
@jeffersonnnn yeah, just realized misreading.
Pieter Stokkink
@forkerino
Aug 10 2017 08:29
@WAINGOR :wave:
Long Nguyen
@longnt80
Aug 10 2017 08:29
@WAINGOR maybe you just type too fast
WAINGOR
@WAINGOR
Aug 10 2017 08:30
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
@WAINGOR sorry.
@WAINGOR I assure you I just arrived here myself.
;)
WAINGOR
@WAINGOR
Aug 10 2017 08:31
np np :)
Long Nguyen
@longnt80
Aug 10 2017 08:31
@WAINGOR nice, my favourite childhood character
Pieter Stokkink
@forkerino
Aug 10 2017 08:31
@WAINGOR any chance for a meetup this weekend?
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:31
@forkerino Hello :wave:
Pieter Stokkink
@forkerino
Aug 10 2017 08:31
@abhinav-thinktank Hi
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:31
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
@forkerino saturday? :) I'll text the boys and see who's willing
Pieter Stokkink
@forkerino
Aug 10 2017 08:32
Still have to do that one. I was thinking of using Redux.
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:32
for this?
yeah me too
:O
Pieter Stokkink
@forkerino
Aug 10 2017 08:32
@WAINGOR I'm game!
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:32
Anybody who's done the game of life here
Pieter Stokkink
@forkerino
Aug 10 2017 08:32
@abhinav-thinktank Haven't had much time for FCC since I got hired.
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:32
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
@abhinav-thinktank I know it is possible without Redux, but it might make things easier.
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:33
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
@abhinav-thinktank decisions, decisions!
Jefferson
@jeffersonnnn
Aug 10 2017 08:34
@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
: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
@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
@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
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
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
@abhinav-thinktank what data were you thinking of storing?
WAINGOR
@WAINGOR
Aug 10 2017 08:35
pls forgive
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:35
@forkerino won't i need a matrix
Pieter Stokkink
@forkerino
Aug 10 2017 08:36
@abhinav-thinktank like a 2d array?
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:36
yea
Pieter Stokkink
@forkerino
Aug 10 2017 08:36
yes
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:36
@forkerino im wondering how im gonna utilize components in this for state change
Pieter Stokkink
@forkerino
Aug 10 2017 08:36
how would the elements look? Will you just store 1/0 for alive/dead?
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:36
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
yes
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:37
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
@forkerino just that? Amazingly concise. Thank you plenty much.
CamperBot
@camperbot
Aug 10 2017 08:38
jeffersonnnn sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: jeffersonnnn already gave forkerino points
Pieter Stokkink
@forkerino
Aug 10 2017 08:38
:+1:
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:38
or should i make a main component
Pieter Stokkink
@forkerino
Aug 10 2017 08:38
@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
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

@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
@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
@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
@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
@forkerino yeah :D well thanks!
CamperBot
@camperbot
Aug 10 2017 08:39
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
Im enjoying react now
in baby steps :P
WAINGOR
@WAINGOR
Aug 10 2017 08:40
@jeffersonnnn WAIT. PLS DONT. I'M SORRY OK
Pieter Stokkink
@forkerino
Aug 10 2017 08:40
@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
aah
Pieter Stokkink
@forkerino
Aug 10 2017 08:40
But at least we use redux
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:40
cool :+1:
WAINGOR
@WAINGOR
Aug 10 2017 08:40
I luvvvvvv Node
Abhinav Mishra
@abhinav-m
Aug 10 2017 08:40
nice
WAINGOR
@WAINGOR
Aug 10 2017 08:41
finishing up my first programme in it
Pieter Stokkink
@forkerino
Aug 10 2017 08:41
@WAINGOR woot woot
@WAINGOR for FCC? or something else?
WAINGOR
@WAINGOR
Aug 10 2017 08:41
it's a private project that I am making for my dad's store @forkerino
Pieter Stokkink
@forkerino
Aug 10 2017 08:42
coolcoolcool
WAINGOR
@WAINGOR
Aug 10 2017 08:42
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
sure thing!
Jefferson
@jeffersonnnn
Aug 10 2017 08:43
@kumquatfelafel hmm. extra insight. i love how you did this. Thank you too. FCC rocks.
CamperBot
@camperbot
Aug 10 2017 08:43
jeffersonnnn sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 592 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Jefferson
@jeffersonnnn
Aug 10 2017 08:44
@WAINGOR LMAO
Pieter Stokkink
@forkerino
Aug 10 2017 08:45
@WAINGOR are you building something complete with payment processing and stuff?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 08:45
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
@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
ah, I think I get it now
Theofanis Despoudis
@theodesp
Aug 10 2017 09:00
Pieter Stokkink
@forkerino
Aug 10 2017 09:00
@theodesp looks familiar
:laughing:
Abhishek Kumar Pandey
@abhishekpandeykr
Aug 10 2017 09:01
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
visit the Angular 4 channel
Abhishek Kumar Pandey
@abhishekpandeykr
Aug 10 2017 09:03
@theodesp i did bro!
LovingVi
@LovingVi
Aug 10 2017 09:06

'''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
:bulb: to format code use backticks! ``` more info
Markus Kiili
@Masd925
Aug 10 2017 09:08
@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
@Masd925 TKS
/'''js
code
/'''
CamperBot
@camperbot
Aug 10 2017 09:16
:bulb: to format code use backticks! ``` more info
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:33

@LovingVi ```, not '''.

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

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

``` 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
@Freedom41 you're returning too early.
Brian
@BrianCodes33
Aug 10 2017 09:41
any JS pros
Mark Mascarenhas
@Freedom41
Aug 10 2017 09:41
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
@Freedom41 Are you looping the second string characters?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:46

@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
@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
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
I get it :) Thanks so much @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 09:52
freedom41 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 593 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:54
@BrianCodes33 so basically, operating on columns as opposed to rows, yes?
Brian
@BrianCodes33
Aug 10 2017 09:54
yea
Mark Mascarenhas
@Freedom41
Aug 10 2017 09:54
@Masd925 the code is not checking all letters
Ill try now Thanks :)
Brian
@BrianCodes33
Aug 10 2017 09:55
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
@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
[0][0]
[1][0]
etc..
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:59
So i is changing, but j is not.
Brian
@BrianCodes33
Aug 10 2017 09:59
right
kumquatfelafel
@kumquatfelafel
Aug 10 2017 09:59
Now in your inner for loop, which is changing? j or i?
Brian
@BrianCodes33
Aug 10 2017 10:00
j
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:00
do we want j to be the one that's changing?
Brian
@BrianCodes33
Aug 10 2017 10:00
no
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:01
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
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
@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
:point_up:
Brian
@BrianCodes33
Aug 10 2017 10:09
Ok
why do i want to reverse
Pieter Stokkink
@forkerino
Aug 10 2017 10:10
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
im too tired to think
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:12

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
@BrianCodes33 if you are too tired to think it is time to take a break. :)
Brian
@BrianCodes33
Aug 10 2017 10:13
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
:+1:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:14
grats :)
what did you come up with?
Brian
@BrianCodes33
Aug 10 2017 10:15
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
Did you add spaces between the words?
Brian
@BrianCodes33
Aug 10 2017 10:16
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
@BrianCodes33 it's because not everything is a "square" array.
Brian
@BrianCodes33
Aug 10 2017 10:18
right there are empty strings
hmm
Pieter Stokkink
@forkerino
Aug 10 2017 10:19
@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
:point_up: this too.
Pieter Stokkink
@forkerino
Aug 10 2017 10:19
The empty strings shouldn't matter
Brian
@BrianCodes33
Aug 10 2017 10:23
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
add space after every index change
LUL
in the first array
Brian
@BrianCodes33
Aug 10 2017 10:26
LUL?
Bartosz
@CataciD
Aug 10 2017 10:26
lol
Brian
@BrianCodes33
Aug 10 2017 10:26
are you laughing at me
Bartosz
@CataciD
Aug 10 2017 10:26
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
@BrianCodes33 do you have a return output.join(' '); "space" for join
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:29

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
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
if j===0 output.push(' ')
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:30
See @heroiczero hint
Pieter Stokkink
@forkerino
Aug 10 2017 10:30
wouldn't that put spaces between each letter?
Bartosz
@CataciD
Aug 10 2017 10:31
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
oh wait... pushing each character... nvm. then join won't work. Not without modification anyway.
Bartosz
@CataciD
Aug 10 2017 10:31
[0][0] is the first word
[0][1] is the second word
and so on
Pieter Stokkink
@forkerino
Aug 10 2017 10:32
@CataciD sorry was talking about @heroiczero 's hint
Bartosz
@CataciD
Aug 10 2017 10:32
k
yeah joining here is pointless
Pieter Stokkink
@forkerino
Aug 10 2017 10:32
I just solved it with map/reduce/join hypercombo
Bartosz
@CataciD
Aug 10 2017 10:32
cause the arrays contain rows of letters
ye would be the same
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:32
@forkerino yeah. We were operating off of the "develop words then join" mindset :p
Bartosz
@CataciD
Aug 10 2017 10:32
brians function is good
only add a condition for pushing space when j===0
Brian
@BrianCodes33
Aug 10 2017 10:33
tried it @CataciD
Pieter Stokkink
@forkerino
Aug 10 2017 10:33
or push a space after the inner loop
and trim the result
Bartosz
@CataciD
Aug 10 2017 10:33
ye same
Brian
@BrianCodes33
Aug 10 2017 10:34
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
theres a space at the begining
Pieter Stokkink
@forkerino
Aug 10 2017 10:34
@BrianCodes33 yeah, it doesn't work with arrays that have different height/width
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:35
@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
if j===0 && i!==0
do that
Pieter Stokkink
@forkerino
Aug 10 2017 10:35
because of the order of the loop
s
Brian
@BrianCodes33
Aug 10 2017 10:35
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
@BrianCodes33 yeah, it doesn't work with arrays that have different height/width
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:36
@BrianCodes33 See what I said earlier. :point_up: August 10, 2017 6:29 AM
Pieter Stokkink
@forkerino
Aug 10 2017 10:36
First loop over arr[0], inside loop over arr
Brian
@BrianCodes33
Aug 10 2017 10:36
yea so how do i account for that
Bartosz
@CataciD
Aug 10 2017 10:37
did you try mine?
did it work
Brian
@BrianCodes33
Aug 10 2017 10:37
only first test passed @CataciD
Bartosz
@CataciD
Aug 10 2017 10:37
and the second?
Brian
@BrianCodes33
Aug 10 2017 10:37
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
why does it add spaces at the end T.T
Brian
@BrianCodes33
Aug 10 2017 10:37
because of what @kumquatfelafel said
Pieter Stokkink
@forkerino
Aug 10 2017 10:37
@BrianCodes33 First loop over arr[0], inside loop over arr
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:38
:point_up:
Pieter Stokkink
@forkerino
Aug 10 2017 10:38
that's what I meant with reverse the order of the loops
Brian
@BrianCodes33
Aug 10 2017 10:38
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
@BrianCodes33 the for loop you have on the inside should be on the outside.
and vice versa
Bartosz
@CataciD
Aug 10 2017 10:39
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
@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
and make a 0 out of i
Bartosz
@CataciD
Aug 10 2017 10:40
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
@CataciD maybe the pushing needs to change, but it's the only way to solve
(with loops)
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:40
yes, the push has to go back to arr[i][j] as opposed to [j][i]
Brian
@BrianCodes33
Aug 10 2017 10:40
my brain hurts lol
Bartosz
@CataciD
Aug 10 2017 10:41
why
@kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:42
@CataciD Because the 2d array might not be square.
Bartosz
@CataciD
Aug 10 2017 10:42
if hes gonna do [i][j] then push em
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:42
row length may be different than column length
Bartosz
@CataciD
Aug 10 2017 10:42
yes
but the point is
he wont push the words
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:42
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
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
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
... Now I'm confused. :laughing:
Markus Kiili
@Masd925
Aug 10 2017 10:45
@ccs99817 It would be enough to consider the basis of Roman numerals:
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:45
off for now.
Markus Kiili
@Masd925
Aug 10 2017 10:45
  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
@ccs99817 You won't need all the intermediate numerals.
heroiczero
@heroiczero
Aug 10 2017 10:45
@ccs99817 you dont really need all the numbers from 0 to 10 and 10 to 100
Pieter Stokkink
@forkerino
Aug 10 2017 10:45
i.e. what @Masd925 said
Ccs99817
@ccs99817
Aug 10 2017 10:46
@heroiczero @forkerino This is the solution come in my mind in short ><
Markus Kiili
@Masd925
Aug 10 2017 10:46
@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
@Masd925 Can u show me that?
Pieter Stokkink
@forkerino
Aug 10 2017 10:47
@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
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
I remember a huge switch statement
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:47
But it only works on FCC
Pieter Stokkink
@forkerino
Aug 10 2017 10:48
@kumquatfelafel I'm intrigued
Ccs99817
@ccs99817
Aug 10 2017 10:48
@forkerino So, you simply the code when you become more and more mature?
Pieter Stokkink
@forkerino
Aug 10 2017 10:48
@ccs99817 yes
simplify
and clean it all up
Ccs99817
@ccs99817
Aug 10 2017 10:49
@forkerino >< sorry for typo.
kumquatfelafel
@kumquatfelafel
Aug 10 2017 10:49
about @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 10:49
:cookie: 593 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Ccs99817
@ccs99817
Aug 10 2017 10:49
How long did you get to become mature?
@ccs99817 yes
Pieter Stokkink
@forkerino
Aug 10 2017 10:49
@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
@forkerino It's also my Map the Debris solution :point_up: :point_up:
Ccs99817
@ccs99817
Aug 10 2017 10:50
I have thought of map
Pieter Stokkink
@forkerino
Aug 10 2017 10:50
@kumquatfelafel lol
Ccs99817
@ccs99817
Aug 10 2017 10:51
But, i forget how to use it
Pieter Stokkink
@forkerino
Aug 10 2017 10:51
hackz0r
Markus Kiili
@Masd925
Aug 10 2017 10:51
@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
@Masd925 check his map the debris 'solution'
CamperBot
@camperbot
Aug 10 2017 10:51
:cookie: 593 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
heroiczero
@heroiczero
Aug 10 2017 10:52
Is there a way to use it without letters?
Ccs99817
@ccs99817
Aug 10 2017 10:52
thx @forkerino @Masd925 @kumquatfelafel
CamperBot
@camperbot
Aug 10 2017 10:52
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
@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
how to get weather icons in codepen
.?
Pieter Stokkink
@forkerino
Aug 10 2017 10:53
@Masd925 that's not the easiest to read.
:laughing:
Blauelf
@Blauelf
Aug 10 2017 10:54
Wow. num and NUM.
Bartosz
@CataciD
Aug 10 2017 10:54
HERE WE GO
Markus Kiili
@Masd925
Aug 10 2017 10:54
@forkerino Was this a readability competition. No :rat:
Bartosz
@CataciD
Aug 10 2017 10:54
two dickwavers gonna fight :D
Ccs99817
@ccs99817
Aug 10 2017 10:55
@Masd925 tbh, it's a bit hard to read
Pieter Stokkink
@forkerino
Aug 10 2017 10:55
@Masd925 :smile:
Markus Kiili
@Masd925
Aug 10 2017 10:55
@ccs99817 Yeah, just made it to prove that it can be done.
Ccs99817
@ccs99817
Aug 10 2017 10:56
@Masd925 at least, it's efficient
Markus Kiili
@Masd925
Aug 10 2017 10:56
@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
There's no IOCCC for JS.
Markus Kiili
@Masd925
Aug 10 2017 11:00
@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
:cry:
Bartosz
@CataciD
Aug 10 2017 11:04

nobully

Blauelf
@Blauelf
Aug 10 2017 11:07
Now the question is: Does a Bully run on Diesel? If so, when did Volkswagen start cheating?
kumquatfelafel
@kumquatfelafel
Aug 10 2017 11:08
@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
@prakashyadav008 Which API are you using for weather
Pieter Stokkink
@forkerino
Aug 10 2017 11:12

@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

ah... perfect! Thanks

so it might be made more elegant

I'll survive. :p ;)

Razvan Jackson
@RazvanJackson
Aug 10 2017 11:31
Hello
Markus Kiili
@Masd925
Aug 10 2017 11:31
@RazvanJackson Yo.
Pieter Stokkink
@forkerino
Aug 10 2017 11:31
Hi
Razvan Jackson
@RazvanJackson
Aug 10 2017 11:32
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
@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
@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
@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

@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
Thanks guys :)
Blauelf
@Blauelf
Aug 10 2017 11:53
And I thought it were a unicorn that had to die. What a scam.
Thayyeb salim
@Thayyebsalim
Aug 10 2017 11:56
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
@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
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
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
Blauelf
@Blauelf
Aug 10 2017 12:20
@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
@heroiczero Thank you so much for your help.
CamperBot
@camperbot
Aug 10 2017 12:26
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
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
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
@EneCatalin Do the conversion for the presentation only, but store the original number.
heroiczero
@heroiczero
Aug 10 2017 12:32
@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

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
S+ ?
heroiczero
@heroiczero
Aug 10 2017 12:46
@WAINGOR maybe use replace with regexp
Ene Catalin
@EneCatalin
Aug 10 2017 12:47
@Blauelf great idea, thanks
CamperBot
@camperbot
Aug 10 2017 12:47
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
quite amazed I didn't think about it :|
@CataciD you look like skallagrim :D
Bartosz
@CataciD
Aug 10 2017 12:49
thanks
dunno who that is but ill treat is as a compliment
Ene Catalin
@EneCatalin
Aug 10 2017 12:49
a youtuber
Bartosz
@CataciD
Aug 10 2017 12:49
i dont usually do youtubers
most content is shit
i only watch related things :^0
Markus Kiili
@Masd925
Aug 10 2017 12:50
@EneCatalin Me too. Tell me that my nose is pretty.
Ene Catalin
@EneCatalin
Aug 10 2017 12:50
I don't dig noses
Blauelf
@Blauelf
Aug 10 2017 12:50
And I thought you meant Skalla-Grímr...
Bartosz
@CataciD
Aug 10 2017 12:50
same shit
in short
"wow u look like that viking dude"
pretty standard
Ene Catalin
@EneCatalin
Aug 10 2017 12:51
^
Bartosz
@CataciD
Aug 10 2017 12:51
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

@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
@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
You can search
Blauelf
@Blauelf
Aug 10 2017 13:17
@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
thanks @Blauelf , awesome as always <3
CamperBot
@camperbot
Aug 10 2017 13:19
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
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
@sjames1958gm fcc weather api
codeolas
@codeolas
Aug 10 2017 15:10
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
can someone help me out with a minor rails issue?
Jefferson
@jeffersonnnn
Aug 10 2017 15:12
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
@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
@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
@JLuboff Is the clone() any good
Jason Luboff
@JLuboff
Aug 10 2017 15:16
@Thayyebsalim I've never used it
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:16
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
@Blauelf That's an idea... Thanks!
CamperBot
@camperbot
Aug 10 2017 15:19
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
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
set width n margins ?
Stephen James
@sjames1958gm
Aug 10 2017 15:35
@Thayyebsalim You can use flex-wrap:wrap; in your offline section
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:36
isn't that the default
Stephen James
@sjames1958gm
Aug 10 2017 15:37
@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
Thanks @sjames1958gm
CamperBot
@camperbot
Aug 10 2017 15:39
thayyebsalim sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Aug 10 2017 15:39
@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
:star2: 8286 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:39
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
@Thayyebsalim lol
Thayyeb salim
@Thayyebsalim
Aug 10 2017 15:41
:D
Kelechi Chinaka
@ke1echi
Aug 10 2017 15:55
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
@kelechy I think you can not nest ternary operator, use if else instead
Christopher McCormack
@cmccormack
Aug 10 2017 16:07
you can nest but this is not quite accurate
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:07
same result, i just cant point where am making that logical mistake @ghulamshabir
Christopher McCormack
@cmccormack
Aug 10 2017 16:07

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
the nesting looks clean to me
Christopher McCormack
@cmccormack
Aug 10 2017 16:07
I think, let me check
Stephen James
@sjames1958gm
Aug 10 2017 16:09
@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
the logic was if the condition are met the Hobo is the else conditon @sjames1958gm
Stephen James
@sjames1958gm
Aug 10 2017 16:12
@kelechy But every other condition you push
Kelechi Chinaka
@ke1echi
Aug 10 2017 16:12

are not met

yes counting and replace
Blauelf
@Blauelf
Aug 10 2017 16:14
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
@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
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
@Sovember which API?