These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Jul 2017
Bradley Sands
@sandsbe
Jul 06 2017 00:04
Getting my butt kicked on the Smallest Common Multiple challenge. Solved for 3 of the 5 scenarios, but there is something wrong in my code that makes the last two not reach the correct number. Anyone take a look?
Let's see if this sends
For some reason I can't seem to send messages without closing and opening Gitter
Anyone else have this issue before?
Abdoullah Alee U
@abdoullfurya
Jul 06 2017 00:09
Hi everyone
Joseph
@revisualize
Jul 06 2017 00:10
Hi.
Bradley Sands
@sandsbe
Jul 06 2017 00:11
test code
Abdoullah Alee U
@abdoullfurya
Jul 06 2017 00:11
'code'
How do i post code like yours @sandsbe
Bradley Sands
@sandsbe
Jul 06 2017 00:12
Having major posting issues. You tried 'code', its code
Its not an apostrophe, but something very similar
top left of my keyboard
@abdoullfurya did you find the symbol?
Nick Janne
@njanne19
Jul 06 2017 00:14
Hey all,
I finished my Recipe Box and it's totally functional, but now I need to move it to local storage
how do I go about doing that because it is one of the user stories for the challenge
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:14
@abdoullfurya For future: if you write it 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: ``` code goes here ```
or for multiple lines vvv
```
code goes here. make sure you have this on separate line (you can use shift+enter or control+enter)
```
You can also edit your post if you make a mistake by clicking the … that appears when you hover your mouse over your comment.
Abdoullah Alee U
@abdoullfurya
Jul 06 2017 00:15
code
code
Thanks man @kumquatfelafel @sandsbe found it
CamperBot
@camperbot
Jul 06 2017 00:16
abdoullfurya sends brownie points to @kumquatfelafel and @sandsbe :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @sandsbe |http://www.freecodecamp.com/sandsbe
:cookie: 442 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
CallMeOrange
@EgnaroDev
Jul 06 2017 00:17
@abdoullfurya not ``` code ```
do this
```
code
```
code
code
This message was deleted
```
code
```
Jerard Delrosario
@jrardd
Jul 06 2017 00:20
Hi guys, anyone on here familiar with JqueryUI Progress bars?
Lorena
@lore-code
Jul 06 2017 00:20

Hi everyone! I'm starting over at fcc can't seem to get past this exercise....any advice?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
// Your code below this line
var result = "The " + myNoun + " was very " + myAdjective + ". He still " + myVerb + " very " + myAdverb + " into my house!";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

fdemaa
@fdemaa
Jul 06 2017 00:21
Anyone know a good resource to study manipulation of the dom with vanilla js ?
Lorena
@lore-code
Jul 06 2017 00:21
@fdemaa I took a course on udemy they have good coupons many times
Manish Giri
@Manish-Giri
Jul 06 2017 00:21
@lore-code add spaces in between the strings
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:21
@abdoullfurya np. One more thing... if you add js to the end of first set of back ticks like so, you can tell it to format like javascript code.
```js
for (blah in yadayadayada) {
do important stuff while you can and stuff. //Because you can. And stuff.
}
```
becomes
for (blah in yadayadayada) {
  do important stuff while you can and stuff. //Because you can. And stuff.
}
Diego Mayer
@Chrono79
Jul 06 2017 00:21
@lore-code myAdjective + ". He still
Abdoullah Alee U
@abdoullfurya
Jul 06 2017 00:22
@kumquatfelafel Awesome thanks
CamperBot
@camperbot
Jul 06 2017 00:22
abdoullfurya sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: abdoullfurya already gave kumquatfelafel points
CallMeOrange
@EgnaroDev
Jul 06 2017 00:24
@kumquatfelafel blah as always
Robert Fischer
@midknight23
Jul 06 2017 00:25
Can anyone tell me why my menu doesn't work in mobile, but it's almost perfectly fine on desktop? Here's the link: https://codepen.io/midknight23/pen/YQaRKx
MichaelRavid
@MichaelRavid
Jul 06 2017 00:25
Hey everyone
Abdoullah Alee U
@abdoullfurya
Jul 06 2017 00:25
Do u use fcc or does anyone have other free online courses to learn javascript?
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:25
@MCTwoDigitZero I'll have you know that blah is a teaching tool that achieved critical recognition in the Maltese Conference of 1956, and has been widely used ever since! :o
CallMeOrange
@EgnaroDev
Jul 06 2017 00:26
wow lol
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:26
@MichaelRavid hello
CallMeOrange
@EgnaroDev
Jul 06 2017 00:26
@abdoullfurya just fCC
MichaelRavid
@MichaelRavid
Jul 06 2017 00:26
Anyone have trouble with the java exercise where you have to generate a random number?
CallMeOrange
@EgnaroDev
Jul 06 2017 00:26
If you want to be good at JS, relearn it
MichaelRavid
@MichaelRavid
Jul 06 2017 00:26
Can someone help me?
CallMeOrange
@EgnaroDev
Jul 06 2017 00:26
@MichaelRavid Java is different from JavaScript
MichaelRavid
@MichaelRavid
Jul 06 2017 00:26
Javascript*
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:27
@MichaelRavid Sure. What have you tried so far?
MichaelRavid
@MichaelRavid
Jul 06 2017 00:27
@MCTwoDigitZero Im aware
return Math.floor(Math.random() >= myMin && math.random <= myMax) + myMin;
CallMeOrange
@EgnaroDev
Jul 06 2017 00:27
lol
MichaelRavid
@MichaelRavid
Jul 06 2017 00:27
Thats the last solution I came up with
Saif Ur Rahman
@saifsmailbox98
Jul 06 2017 00:27
:wave:, good night
CallMeOrange
@EgnaroDev
Jul 06 2017 00:27
@saifsmailbox98 Night
Robert Fischer
@midknight23
Jul 06 2017 00:27
@abdoullfurya try codecademy, their JavaScript course is pretty basic but their jQuery course is fantastic.
MichaelRavid
@MichaelRavid
Jul 06 2017 00:28
im just confused because in the example given its only one factor we have to consider while the exercise has two
Anyone able to heelp? I feel like im making this more complicated than it needs to be
Manish Giri
@Manish-Giri
Jul 06 2017 00:31
@MichaelRavid post the challenge url.
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:32
@MichaelRavid sorry, had to restart. sec.
MichaelRavid
@MichaelRavid
Jul 06 2017 00:33
@kumquatfelafel & @Manish-Giri thank you
CamperBot
@camperbot
Jul 06 2017 00:33
michaelravid sends brownie points to @kumquatfelafel and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 443 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 6196 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jul 06 2017 00:33
@MichaelRavid did you see the instruction on the left?
Here's the formula we'll use. Take a moment to read it and try to understand what this code is doing:
Math.floor(Math.random() * (max - min + 1)) + min
this also generates a random number between the two ranges max and min
that's exactly what you need to do
MichaelRavid
@MichaelRavid
Jul 06 2017 00:35
But that that doesnt meet the requirements
Manish Giri
@Manish-Giri
Jul 06 2017 00:35
did you change the code according to the variable names?
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:36
@MichaelRavid copy pasting would not meet code requirements, no.
Manish Giri
@Manish-Giri
Jul 06 2017 00:36
Create a function called randomRange that takes a range myMin and myMax
MichaelRavid
@MichaelRavid
Jul 06 2017 00:37
ahh okay
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:37
@MichaelRavid beyond that, do you need any explanation of what is going on with this code/why it would work?
MichaelRavid
@MichaelRavid
Jul 06 2017 00:37
i subbed the variables out and it went through. I understand now
the way it was worded was weird. Thank you everyone!
The greater than or equal to was throwing me off lol
Robert Fischer
@midknight23
Jul 06 2017 00:43
Nobody can help me?
CallMeOrange
@EgnaroDev
Jul 06 2017 00:43
@midknight23 just ask a question here and we'll help you
Robert Fischer
@midknight23
Jul 06 2017 00:45
My portfolio page... I'm updating it, and I am trying to figure out why the menu isn't working for mobile. Here's the link: https://codepen.io/midknight23/pen/YQaRKx
I'm assuming I'm missing something in the JavaScript (jQuery) but I don't know for sure.
I'm not sure if anyone here actually can help me, though, I've looked through the code and it looks fine.
Ethan
@ethannorman
Jul 06 2017 00:53
I need help on Accessing Nested Arrays, here's my solution, but I don't know what I'm doing wrong.
var secondTree = myPlants[1].type.pine;
kumquatfelafel
@kumquatfelafel
Jul 06 2017 00:56
@ethannorman just gonna post the setup so don't have to switch between tabs.
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

//and your attempted solution vvvv
var secondTree = myPlants[1].type.pine;
Pagnito
@Pagnito
Jul 06 2017 00:58
anyone can help with heaps algorithm?
Joseph
@revisualize
Jul 06 2017 00:59
@ethannorman that isn't quite right
@ethannorman what is the value of myPlants[1]?
@ethannorman it's an object with two properties type & list
@kumquatfelafel thanks.
CamperBot
@camperbot
Jul 06 2017 01:01
revisualize sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 444 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Joseph
@revisualize
Jul 06 2017 01:02
@kumquatfelafel 444!!!!!!!!!!!!!!!!!
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:02
@revisualize np :p
Joseph
@revisualize
Jul 06 2017 01:02
@ethannorman The property of type has a value of a string
@ethannorman the object property of list has a value that is an Array.
CamperBot
@camperbot
Jul 06 2017 01:03
mctwodigitzero sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
CallMeOrange
@EgnaroDev
Jul 06 2017 01:03
445 :)
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:03
@MCTwoDigitZero ???
Joseph
@revisualize
Jul 06 2017 01:04
@ethannorman The list array has 3 elements. Each are a string.
CallMeOrange
@EgnaroDev
Jul 06 2017 01:04
@kumquatfelafel 444!!!!!!!!!!!!!!!!!
not anymore
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:04
@MCTwoDigitZero yw? :laughing:
Joseph
@revisualize
Jul 06 2017 01:04
@MCTwoDigitZero I like numeric sequences. So yeah... I congratulate people when the get them in brownie points.
CallMeOrange
@EgnaroDev
Jul 06 2017 01:05
I see
Dont worry, will get 444 soon
about @MCTwoDigitZero
CamperBot
@camperbot
Jul 06 2017 01:05
:cookie: 445 | @mctwodigitzero |http://www.freecodecamp.com/mctwodigitzero
CallMeOrange
@EgnaroDev
Jul 06 2017 01:05
wtf?
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:05
haha
Joseph
@revisualize
Jul 06 2017 01:05
ha ha
CallMeOrange
@EgnaroDev
Jul 06 2017 01:05
@MCTwoDigitZero we have the same cookies lol
Moisés Man
@moigithub
Jul 06 2017 01:05
@midknight23 i see u have this on ur settings...
//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.js
does it open on ur browser ??
CallMeOrange
@EgnaroDev
Jul 06 2017 01:05
I thought I had 430+
Robert Fischer
@midknight23
Jul 06 2017 01:06
Nope
Moisés Man
@moigithub
Jul 06 2017 01:06
@midknight23 then ur link is wrong.. try this
https://www.bootstrapcdn.com/
copy the js url on ur js setttings
CallMeOrange
@EgnaroDev
Jul 06 2017 01:08
@kumquatfelafel you should be on fCC leaderboard
wow revisual is listed 2k but Im listed 84
Robert Fischer
@midknight23
Jul 06 2017 01:10
Alright thanks @moigithub looks like I gotta fix some other problems now but I appreciate your help.
CamperBot
@camperbot
Jul 06 2017 01:10
midknight23 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3467 | @moigithub |http://www.freecodecamp.com/moigithub
abraham anak agung
@padunk
Jul 06 2017 01:19

Hi, could anyone help me explain this:

var i = 0;
var a = {
  ['foo' + ++i]: i,
  ['foo' + ++i]: i,
  ['foo' + ++i]: i
};

console.log(a.foo1); // 1
console.log(a.foo2); // 2
console.log(a.foo3); // 3

why if i put a.foo0 it will print undefined not 0?

Moisés Man
@moigithub
Jul 06 2017 01:21
cuz it dont exist ? :)
pre/post increment
++i vs i++
abraham anak agung
@padunk
Jul 06 2017 01:22
@moigithub oh yesss, i'm stupid...forget that.. thanks
CamperBot
@camperbot
Jul 06 2017 01:22
padunk sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:22
@padunk ++i is pre increment. It adds 1 to i, then executes rest. If you made i++, it will add 1 to i afterwards. https://repl.it/JP4J
CamperBot
@camperbot
Jul 06 2017 01:22
:star2: 3468 | @moigithub |http://www.freecodecamp.com/moigithub
Robert Fischer
@midknight23
Jul 06 2017 01:23
Do any of your console logs work? Cuz they shouldn't @padunk
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:24
@midknight23 why is that? When you say shouldn't work, what do you mean?
abraham anak agung
@padunk
Jul 06 2017 01:24
@kumquatfelafel yes i forget what that pre increment is... :)
Robert Fischer
@midknight23
Jul 06 2017 01:25
I just got schooled. How new is this? I didn't think preincrements worked at all
@kumquatfelafel
@moigithub
Long Nguyen
@longnt80
Jul 06 2017 01:36
I have an issue with mouseup/pointerup event. If I click and drag the pointer out of the target element, the event won't register:
https://codepen.io/longnt80/pen/BZPzWm?editors=1011
@kumquatfelafel hey, I found out that the issue is the event mouseup
not web audio api
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:47
@midknight23 unsure how long pre-increment in and of itself has been around in Javascript if that's what you are asking???? At the very least though, 11 years. https://muffinresearch.co.uk/getelementsbyclassname-deluxe-edition/ You can see talk about it in comments. But I wouldn't be surprised to find it's been around for a fair amount longer. I don't feel like finding something more precise though. :p
kumquatfelafel
@kumquatfelafel
Jul 06 2017 01:54
@midknight23 (if your question more along the lines of what @moigithub mentioned, then still don't know when exactly, but certainly not that long ago. :p )
@longnt80 interestoing
Long Nguyen
@longnt80
Jul 06 2017 01:56
@kumquatfelafel the issue only happens when I click the button and the pointer changes to a disabled icon
if the pointer doesn't change to a disabled icon then it works as expected
kumquatfelafel
@kumquatfelafel
Jul 06 2017 02:02
I... I suppose you could make it a purely keyboard Simon Says. :p
kumquatfelafel @kumquatfelafel keeps a straight face
kumquatfelafel
@kumquatfelafel
Jul 06 2017 02:03
It's not like key events could cause any problems.
@longnt80 but on serious note, not sure of solution.
Matt
@DaftlyPunkish
Jul 06 2017 02:06
Hey guys, I have a question about the twitch streamer status project
The updated JSON call that they give you. I don't think it has an online or offline status data call
There's a "status" call but that doesn't actually show whether or not they are online.
abraham anak agung
@padunk
Jul 06 2017 02:11
@DaftlyPunkish use streams instead of channels. if stream is null, the user is offline
Guderian Raborg
@hypercuber
Jul 06 2017 02:11
How can I do this in one line
var arr = [1,2,2,2,3,4];
arr = arr.filter(n => {
  if (n !== 2) {
    return n;
}});
Matt
@DaftlyPunkish
Jul 06 2017 02:12
@padunk Are you talking about in the URL?
abraham anak agung
@padunk
Jul 06 2017 02:12
@DaftlyPunkish yes
Matt
@DaftlyPunkish
Jul 06 2017 02:12
@padunk Ayyyy that did it!
Thank you!
@padunk Thank you!
CamperBot
@camperbot
Jul 06 2017 02:12
daftlypunkish sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @padunk |http://www.freecodecamp.com/padunk
abraham anak agung
@padunk
Jul 06 2017 02:13
@DaftlyPunkish :+1:
Moisés Man
@moigithub
Jul 06 2017 02:14
arr.filter(n => n!==2 ? n : undefined)
abraham anak agung
@padunk
Jul 06 2017 02:14
arr.filter (n => n !==2 ? n: null)
Moisés Man
@moigithub
Jul 06 2017 02:14
:D
abraham anak agung
@padunk
Jul 06 2017 02:15
:smile: can null be use? @moigithub
Moisés Man
@moigithub
Jul 06 2017 02:15
ofc
abraham anak agung
@padunk
Jul 06 2017 02:15
:+1:
Moisés Man
@moigithub
Jul 06 2017 02:16
probably 0 will be shorter
since filter requires a truthy or falsy values
0, "", undefined, null, NaN :point_left: falsy values
Long Nguyen
@longnt80
Jul 06 2017 02:44
@kumquatfelafel finally, I found the source of the issue and the solution!!
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:26
@longnt80 woot! :)
Ednor
@ednor
Jul 06 2017 03:28
Hello hello !
Long time I didn't ask for help
How is everything ?
caneno
@caneno
Jul 06 2017 03:29
hi guys I am having trouble with my code
MoeClean
@MoeClean
Jul 06 2017 03:30
lets see your code @caneno
caneno
@caneno
Jul 06 2017 03:31
function titleCase(str) {
  var newWord = str.split(" ");
    var newArr = [];
    var newStr = "";
for(var i = 0; i < newWord.length; i++){
    newArr[i] = newWord[i].charAt(0).toUpperCase() + newWord[i].slice(0);
    newStr = newArr.join(" ");
}
  return newStr;
}

titleCase("I'm a little tea pot");
Long Nguyen
@longnt80
Jul 06 2017 03:31
@kumquatfelafel I just disabled the drag and drop (user select) feature
caneno
@caneno
Jul 06 2017 03:31
I need to get the first letter capitalize
but I getting two first letters
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:32

hmmm...

It doesn't seem to be running properly on my browser. @longnt80

Long Nguyen
@longnt80
Jul 06 2017 03:33
@kumquatfelafel what happened?
@kumquatfelafel which browser?
caneno
@caneno
Jul 06 2017 03:34
that link doesnt work
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:34
@longnt80 No longer any response to click (or if is, not doing anything). Firefox 54.0.1 (64-bit)
Joseph
@revisualize
Jul 06 2017 03:34
@caneno I fixed it. I am typing one handed. Sorry about that.
@caneno what is newWord[i].slice(0); when i is 0?
Long Nguyen
@longnt80
Jul 06 2017 03:36
@kumquatfelafel ok let me check
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:36
@longnt80 Yeah, it's not registering the click.
Using a trackpad as opposed to mouse if that's important(no idea)
caneno
@caneno
Jul 06 2017 03:38
@revisualize the newWord is the string split into an array, and newWord[i] loops into the string arrays to cap the first letters
Joseph
@revisualize
Jul 06 2017 03:38
@caneno come on.
@caneno what is newWord[i].slice(0); when i is 0?
@caneno I'm looking for an exact answer here.
caneno
@caneno
Jul 06 2017 03:40
the first letter?
Joseph
@revisualize
Jul 06 2017 03:41
@kumquatfelafel What is your favorite color? Mine is ... a shade of gradient that meshes two colors in the spectrum of grey with a combination of blue.
@caneno No.
MoeClean
@MoeClean
Jul 06 2017 03:41
oh... @caneno is so close!
caneno
@caneno
Jul 06 2017 03:41
got i
Joseph
@revisualize
Jul 06 2017 03:41
@caneno no.
caneno
@caneno
Jul 06 2017 03:41
no I mean I got it fixed
Joseph
@revisualize
Jul 06 2017 03:41
@caneno It isn't
MoeClean
@MoeClean
Jul 06 2017 03:42
ay good job mayn...
Joseph
@revisualize
Jul 06 2017 03:42
@caneno that is not correct
caneno
@caneno
Jul 06 2017 03:43
function titleCase(str) {
  var newWord = str.split(" ");
    var newArr = [];
    var newStr = "";
for(var i = 0; i < newWord.length; i++){
    newArr[i] = newWord[i].charAt(0).toUpperCase() + newWord[i].slice(1);
    newStr = newArr.join(" ");
}
  return newStr;
}

titleCase("I'm a little tea pot");
Joseph
@revisualize
Jul 06 2017 03:43
@caneno grats
Long Nguyen
@longnt80
Jul 06 2017 03:44
@kumquatfelafel hmm, it's still working on my Firefox (32-bit) but not IE
caneno
@caneno
Jul 06 2017 03:44
@revisualize thanks
CamperBot
@camperbot
Jul 06 2017 03:44
caneno sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4315 | @revisualize |http://www.freecodecamp.com/revisualize
caneno
@caneno
Jul 06 2017 03:44
what was that link I like it it was really useful
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:44
@longnt80 I tried disabling add-ons just in case they were somehow interfering. mousedown seems to work, but pointerdown isn't.
Joseph
@revisualize
Jul 06 2017 03:45
@caneno now figure out how to do that without using the newStr variable
Anthony Contreras
@AmazeCPK
Jul 06 2017 03:46
Am I okay with having user forms saved into the database? should I follow any kind of sanitizing procedure? I'm using query builders to sanitize any kind of sql injection already
caneno
@caneno
Jul 06 2017 03:46
@revisualize wokring on it
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:46
@longnt80 Add a warning, "kumquatfelafel, this will not work on your meh computer/browser"? :p
Long Nguyen
@longnt80
Jul 06 2017 03:47
@kumquatfelafel hah
@kumquatfelafel can you try this sample: https://codepen.io/longnt80/full/zzLKoo/
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:48
@longnt80 okay... when I click, in log it says, " type error gain is null.
Long Nguyen
@longnt80
Jul 06 2017 03:48
it uses the same method
caneno
@caneno
Jul 06 2017 03:49
@revisualize
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:49
@longnt80 k. sec
Joseph
@revisualize
Jul 06 2017 03:49
@caneno Sup?
caneno
@caneno
Jul 06 2017 03:49
function titleCase(str) {
  var newWord = str.split(" ");
    var newArr = [];
for(var i = 0; i < newWord.length; i++){
    newArr[i] = newWord[i].charAt(0).toUpperCase() + newWord[i].slice(1);
}
  return newArr.join(" ");
}

titleCase("I'm a little tea pot");
that can work
Joseph
@revisualize
Jul 06 2017 03:49
@caneno ok
John
@flyboy1565
Jul 06 2017 03:49
any cleaner way to write this?
function create_issue(obj){
    if (!obj['created']  && !obj['feature']){
        var issue = {
        created: false,
        confirmed: obj['confirmed'],
        down_since: Date.parse(obj['down_since']),
        issue_id: obj['id'],
        issue_type: obj['issue'],
        ticket: obj['ticket]'],
        resolved: obj['resolved'],
        latitdue: obj['store']['latitude'],
        longitude: obj['store']['longitude'],
        state: obj['store']['state'],
        store: obj['store']['store_number'],
        work_on: obj['workon'],
        make_slug: function(){ this.slug= (this.store + '-' + this.issue_id + '-' + this.issue_type + '-' + this.created + '-' + this.confirmed)}
    }
    }
    else{
        var issue = {
        created: obj['created'],
        confirmed: obj['feature']['confirmed'],
        down_since: Date.parse(obj['feature']['down_since']),
        issue_id: obj['feature']['id'],
        issue_type: obj['feature']['issue'],
        ticket: obj['feature']['ticket]'],
        resolved: obj['feature']['resolved'],
        latitdue: obj['feature']['store']['latitude'],
        longitude: obj['feature']['store']['longitude'],
        state: obj['feature']['store']['state'],
        store: obj['feature']['store']['store_number'],
        work_on: obj['feature']['workon'],
        make_slug: function(){ this.slug= (this.store + '-' + this.issue_id + '-' + this.issue_type + '-' + this.created + '-' + this.confirmed)}
    }
    }
    issue.make_slug()
    return issue
}
Joseph
@revisualize
Jul 06 2017 03:50
@caneno now do it without using the newArr variable
caneno
@caneno
Jul 06 2017 03:50
@revisualize On it
Joseph
@revisualize
Jul 06 2017 03:51
@caneno I'm not trying to be a jerk. I just thought I'd talk to someone about code refactoring.
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:51
@longnt80 Okay, on this one, when mousedown, registers the click... when pointerdown, no errors, but nothing happens either.
Joseph
@revisualize
Jul 06 2017 03:51
@caneno you just have to change 2 lines of code and delete the var newArr = [];
caneno
@caneno
Jul 06 2017 03:52
@revisualize I don't think that you are a jerk, I really appreciate what your doing
function titleCase(str) {
  var newWord = str.split(" ");
for(var i = 0; i < newWord.length; i++){
    newWord[i] = newWord[i].charAt(0).toUpperCase() + newWord[i].slice(1);
}
  return newWord.join(" ");
}

titleCase("I'm a little tea pot");
Joseph
@revisualize
Jul 06 2017 03:52
@caneno indent your for so that it looks like it is in the function.
Long Nguyen
@longnt80
Jul 06 2017 03:53
@kumquatfelafel the square doesn't change color?
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:53
@longnt80 square changes color for mousedown, but not pointerdown
Long Nguyen
@longnt80
Jul 06 2017 03:53
@kumquatfelafel ok maybe pointerdown is not supported yet
Joseph
@revisualize
Jul 06 2017 03:53
@caneno How does that code feel over what you had orig?
Long Nguyen
@longnt80
Jul 06 2017 03:54
@kumquatfelafel it's working on my Firefox but not IE(Edge), only the Simon doesn't work, the other still work on my IE
caneno
@caneno
Jul 06 2017 03:55
@revisualize It feel so much better and easy to look at thank for the help. NowI have to figure out how to make the other letters lower case
CamperBot
@camperbot
Jul 06 2017 03:55
caneno sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: caneno already gave revisualize points
Joseph
@revisualize
Jul 06 2017 03:55
@caneno also, is newWord a descriptive variable name?
kumquatfelafel
@kumquatfelafel
Jul 06 2017 03:55
@longnt80 possibly.
caneno
@caneno
Jul 06 2017 03:55
@revisualize yeah
Joseph
@revisualize
Jul 06 2017 03:55
@caneno how do you make letters lowercase?
caneno
@caneno
Jul 06 2017 03:56
I don't know I am figuring it out
Joseph
@revisualize
Jul 06 2017 03:56
@caneno I don't think newWord is a descriptive variable name.
Long Nguyen
@longnt80
Jul 06 2017 03:57
@kumquatfelafel I think it has to do with jQuery selector using data attribute
Joseph
@revisualize
Jul 06 2017 03:57
@caneno I think strArr, strArray, wordsArray, arrOfWords, arrWords ... would be more descriptive
caneno
@caneno
Jul 06 2017 03:58
@revisualize I was about to ask an example of descriptive variables
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:00
so i just finished the "Stand In Line" challenge, but only because I looked up the solution. I don't understand how the solution works. Can someone help me work it out?
or help me understand it?
Joseph
@revisualize
Jul 06 2017 04:00
@FREExM1ND I can
@FREExM1ND What is your function (code)?
theres the challenge
Joseph
@revisualize
Jul 06 2017 04:01
@FREExM1ND I know.
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:01
@revisualize im just trying to understand the solution because i didn't even know where to begin
Joseph
@revisualize
Jul 06 2017 04:01
@FREExM1ND I have a huge write-up on the challenge.
@FREExM1ND Do you have a solution?
@FREExM1ND or do you want to work out your own solution?
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:03
@revisualize i don't have a solution, i clicked "get a hint" and looked up the solution that way
Joseph
@revisualize
Jul 06 2017 04:03
@FREExM1ND ok
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:03
@revisualize i really don't really know where to begin or how the solution given works
Joseph
@revisualize
Jul 06 2017 04:03
@FREExM1ND Ok
@FREExM1ND first off: do you know what parameters are?
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:05
@revisualize not sure what you mean
@revisualize like what the instrustions say to do?
Joseph
@revisualize
Jul 06 2017 04:05
@FREExM1ND no.
@FREExM1ND I'm asking a general question.
kumquatfelafel
@kumquatfelafel
Jul 06 2017 04:06
@FREExM1ND Instructions can have parameters of a sort, but in javascript, means something different. ;)
Joseph
@revisualize
Jul 06 2017 04:06
@FREExM1ND I'm trying to figure out how to help.
@FREExM1ND I could just link you some stuff.
Or I could work with you.
It depends on what you want.
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:07
@revisualize let me check out that link and then we can go from there?
caneno
@caneno
Jul 06 2017 04:07
@revisualize I got it what do you think?
function titleCase(str) {
  var strArray = str.toLowerCase();
  strArray = strArray.split(" ");
for(var i = 0; i < strArray.length; i++){
    strArray[i] = strArray[i].charAt(0).toUpperCase() + strArray[i].slice(1);
}
  return strArray.join(" ");
}

titleCase("I'm a little tea pot");
Joseph
@revisualize
Jul 06 2017 04:08
@caneno combine these:
var strArray = str.toLowerCase();
strArray = strArray.split(" ");
kumquatfelafel
@kumquatfelafel
Jul 06 2017 04:08
nvm :laughing:
caneno
@caneno
Jul 06 2017 04:09
@revisualize like that?
function titleCase(str) {
  var strArray = str.toLowerCase().split(" ");
for(var i = 0; i < strArray.length; i++){
    strArray[i] = strArray[i].charAt(0).toUpperCase() + strArray[i].slice(1);
}
  return strArray.join(" ");
}

titleCase("I'm a little tea pot");
Joseph
@revisualize
Jul 06 2017 04:10
@caneno does that work?
caneno
@caneno
Jul 06 2017 04:10
yes sir
just ran it
Joseph
@revisualize
Jul 06 2017 04:10
@caneno Also.
@caneno indent your code
@caneno The for doesn't look like it is in the function.
caneno
@caneno
Jul 06 2017 04:11
@revisualize yeah for some reason when I paste it some indentation gets removed
Joseph
@revisualize
Jul 06 2017 04:11
@caneno ok
caneno
@caneno
Jul 06 2017 04:11
function titleCase(str) {
  var strArray = str.toLowerCase().split(" ");
  for(var i = 0; i < strArray.length; i++){
    strArray[i] = strArray[i].charAt(0).toUpperCase() + strArray[i].slice(1);
}
  return strArray.join(" ");
}

titleCase("I'm a little tea pot");
@revisualize There you go
Joseph
@revisualize
Jul 06 2017 04:11
@caneno well the } but, yeah
caneno
@caneno
Jul 06 2017 04:12
@revisualize oops
Joseph
@revisualize
Jul 06 2017 04:12
all good
kumquatfelafel
@kumquatfelafel
Jul 06 2017 04:12
@caneno It's admittedly a little annoying at times to format on here if copy paste issues or anything along those lines. :p
caneno
@caneno
Jul 06 2017 04:13
@revisualize thank you again
CamperBot
@camperbot
Jul 06 2017 04:13
caneno sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: caneno already gave revisualize points
Aaron Robbins
@FREExM1ND
Jul 06 2017 04:13
@revisualize maybe i should sleep before i even try to learn this again xD
Joseph
@revisualize
Jul 06 2017 04:13
@FREExM1ND That's your call.
caneno
@caneno
Jul 06 2017 04:13
@kumquatfelafel I know even more when I use the chrome console to run it fast
kumquatfelafel
@kumquatfelafel
Jul 06 2017 04:16
@FREExM1ND If the example function calls seem overwhelmingly "numbery", don't worry about it too much. You can just think of the array itself as being like the line and each number as being like a person.
Robert Fischer
@midknight23
Jul 06 2017 04:18
@kumquatfelafel I know I'm late but yeah I was talking about what @moigithub was talking about. I noticed it said 2015, and I didn't think the code a.foo would work in a console log. You definitely corrected me though. Gotta apologize for that
kumquatfelafel
@kumquatfelafel
Jul 06 2017 04:19

That being said, I myself will probably call it a night.
@revisualize p.s. blue.

@midknight23 nah. One of the things about being new is you don't always even know enough to know that things were wrong in the past :laughing:

shivam gupta
@shivamg11000
Jul 06 2017 04:19
hey whats the difference between JSON.parse() and .json()
Joseph
@revisualize
Jul 06 2017 04:21
@kumquatfelafel I was being funny
Ogundele Olumide
@Lumexralph
Jul 06 2017 04:21
@shivamg11000 the question i'll ask is where is .json() from, jQuery?
shivam gupta
@shivamg11000
Jul 06 2017 04:21
@Lumexralph I don't know
kumquatfelafel
@kumquatfelafel
Jul 06 2017 04:21
@revisualize I don't understand funny. I'm totally oblivious like that. :o
;)
night
M-C-Haker
@M-C-Haker
Jul 06 2017 04:23
can someone point out what i'm missing so far:

`
function truncateString(str, num) {
if (str.length > num) {
return str.slice(0, num-3) + "...";
}
else if (str.length <= num) {
return str;
}
else if (num <= 3) {
return str.slice(0, num) + "...";
}
}

truncateString("A-", 1);`

Ogundele Olumide
@Lumexralph
Jul 06 2017 04:23
@shivamg11000 you know what JSON is, right?
M-C-Haker
@M-C-Haker
Jul 06 2017 04:23
is my code but for some reason i'm not getting truncateString("A-", 1) should return "A...".
Joseph
@revisualize
Jul 06 2017 04:23
@M-C-Haker You have too many characters
or maybe i'm wrong
M-C-Haker
@M-C-Haker
Jul 06 2017 04:24
@revisualize i'm right on everything except the last else if
for some reason i can't get it to return A...
even though it looks right to me..
Joseph
@revisualize
Jul 06 2017 04:25
@M-C-Haker pythontutor ?
M-C-Haker
@M-C-Haker
Jul 06 2017 04:25
@revisualize i'll give it a go
Bradley Sands
@sandsbe
Jul 06 2017 04:26
Python tutor is the greatest
M-C-Haker
@M-C-Haker
Jul 06 2017 04:27
@revisualize yeah i book marked that last time you suggested it to me lol. looks like this argument fits the paramater of my first if statement so i'm going to have to figure out how to limit it
Joseph
@revisualize
Jul 06 2017 04:27
@M-C-Haker most restrictive first
Aaron Bell
@awb715
Jul 06 2017 04:27
@revisualize you know hbs or d3
M-C-Haker
@M-C-Haker
Jul 06 2017 04:28
@revisualize ok that makes sense thanks
CamperBot
@camperbot
Jul 06 2017 04:28
m-c-haker sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4316 | @revisualize |http://www.freecodecamp.com/revisualize
Bradley Sands
@sandsbe
Jul 06 2017 04:28
Can someone tell me why this loop is infinite? I'm doing the smallest common denominator question.
  var j = 1;
  var counter = 0;
  i = 0;

  while (i < arrRange.length) {
    if (largerNum*j % arr[i] === 0) {
      i++;
    } else {
      j++;
      i = 0;
    }
  }
Joseph
@revisualize
Jul 06 2017 04:28
@awb715 Harvard Business School?
Bradley Sands
@sandsbe
Jul 06 2017 04:29
All I want to do is keep multiplying the larger number and then checking to see if the smaller numbers don't have a remainder.
Joseph
@revisualize
Jul 06 2017 04:29
https://www.packtpub.com/packt/offers/free-learning
Book of the day is:
Learning JavaScript Data Structures and Algorithms
M-C-Haker
@M-C-Haker
Jul 06 2017 04:30
@revisualize the code was solid, was all about the order thanks for pointing out most restrictive first. just had to move that last else if to the first if position. Time to see the better way to do it now and feel terrible about myself lol
CamperBot
@camperbot
Jul 06 2017 04:30
m-c-haker sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: m-c-haker already gave revisualize points
Joseph
@revisualize
Jul 06 2017 04:31
@M-C-Haker don't feel that way
M-C-Haker
@M-C-Haker
Jul 06 2017 04:32
@revisualize ah i'm mostly kidding, but i actually don't feel too bad after reviewing the solutions all were if statements and were pretty similar to eachother
Aaron Bell
@awb715
Jul 06 2017 04:34
Nitin Sahu
@globefire
Jul 06 2017 04:34
image.png
i can't find what is wrong in it ?
Joseph
@revisualize
Jul 06 2017 04:35
@globefire remove the - 1
Nitin Sahu
@globefire
Jul 06 2017 04:36
shit's man never went thru d code :laughing:
how's ur hand ?
Joseph
@revisualize
Jul 06 2017 04:38
@globefire broken.
Heh
as okay as it can be.
Bradley Sands
@sandsbe
Jul 06 2017 04:39
@revisualize thanks for the book of the day. Definitely bookmarking this site.
CamperBot
@camperbot
Jul 06 2017 04:39
sandsbe sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4317 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 06 2017 04:39
my nerve numbing meds are wearing off.
Nitin Sahu
@globefire
Jul 06 2017 04:39
take care man
@camperbot thanks
CamperBot
@camperbot
Jul 06 2017 04:39
globefire sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3365 | @camperbot |http://www.freecodecamp.com/camperbot
M-C-Haker
@M-C-Haker
Jul 06 2017 04:39
@revisualize definitely can relate felt that way about the "return largest numbers in an array" challenege, but i do enjoy the challenge. self-deprecation just kind of help motivates me to get better. great video to stay motivated as well, so ty
CamperBot
@camperbot
Jul 06 2017 04:39
m-c-haker sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: m-c-haker already gave revisualize points
gyadav187
@gyadav187
Jul 06 2017 05:24
Hello can anybody help me?
https://codepen.io/gyadav187/pen/zzLZZo
Abubakar Sambo
@sastech
Jul 06 2017 05:26
@gyadav187 hi, what are you trying to do
I need help with truncating a string!!
gyadav187
@gyadav187
Jul 06 2017 05:28
@sastech i am trying to append the ids of each li element in front of its text using jquery...this is not any project i am just trying to learn jquery
Abubakar Sambo
@sastech
Jul 06 2017 05:41
Ok @gyadav187 ! I'm not good at this, but in your code $("li").append... perhaps you should try adding the text ids $("li[id=' ']:last").append or try using the id directly $("#two").append...
gyadav187
@gyadav187
Jul 06 2017 05:44
@sastech bro i got the answer... i can do this using
  1. .each() method
  2. I wanted to know what was wrong with my code to which i also got the answer ie. "$(this)" is not referring to any single li element but to whole selection
Abubakar Sambo
@sastech
Jul 06 2017 05:46
@gyadav187 great!!
Guys here's my problem ...
function truncatrString(str, num){

var mytrunc = "";  
 if (str.length > num) {
mytrunc = str.slice(0, num-3) + "...";
return mytrunc;

}
return str;
}
It's passing some, not others, from the task list !?
Coy Sanders
@coymeetsworld
Jul 06 2017 05:50
is it passing anything @sastech ?
the function name is not right
Dovydas Stirpeika
@Giveback007
Jul 06 2017 05:51
hey there peeps
wonder
@wonder2991
Jul 06 2017 05:51
@sastech read the instructions
gadzet
@gadzet
Jul 06 2017 05:52
image.png
have to make timeline like this anyone knows what would be best aproach
for the time bar ?
heroiczero
@heroiczero
Jul 06 2017 05:52
@sastech you should have 3 cases of if and else if and a else
gadzet
@gadzet
Jul 06 2017 05:52
svg or the input range ?
Dovydas Stirpeika
@Giveback007
Jul 06 2017 05:52

I am working on a site, and am trying to figure out smooth scroll for what ever reason when I press home it takes me to very top of page rather than below hero header:

https://codepen.io/giveback007/pen/awjmdB?editors=0010

anyone know why?
Long Nguyen
@longnt80
Jul 06 2017 05:54
@gadzet you mean the orange slider?
Abubakar Sambo
@sastech
Jul 06 2017 05:55
@coymeetsworld @wonder2991 yes it passed all except truncateString("A-", 1) should return "A...". and truncateString("Absolutely Longer", 2) should return "Ab...".
gadzet
@gadzet
Jul 06 2017 05:55
@longnt80 right
Coy Sanders
@coymeetsworld
Jul 06 2017 05:55
@sastech there was a typo in your function name, thats why I asked
gadzet
@gadzet
Jul 06 2017 05:55
its going to be in react
Coy Sanders
@coymeetsworld
Jul 06 2017 05:55
but yes you need another if statement to handle that case
gadzet
@gadzet
Jul 06 2017 05:55
dont know how to proceed either by generating the time size and the slider
was thinking to print spans with the timestamp ref
but not sure if it is a good idea
then for the selected timestamp change the classname
Long Nguyen
@longnt80
Jul 06 2017 05:56
@gadzet sorry I don't know react man
Abubakar Sambo
@sastech
Jul 06 2017 05:57
@heroiczero i thought of using else if, but did this instead, I'll try that now
Dovydas Stirpeika
@Giveback007
Jul 06 2017 05:57
no one know?
gadzet
@gadzet
Jul 06 2017 05:58
@longnt80 ok what about others
@longnt80 what approach would u do ?
wonder
@wonder2991
Jul 06 2017 05:58
@sastech i think you could use another conditional statement for maximum string length num is less than or equal to 3
Abubakar Sambo
@sastech
Jul 06 2017 05:59
@coymeetsworld oh i see it, the typo isn't in my original code(on my laptop) it's when i was retyping it here (I'm chatting with the mobile gitter app)
Long Nguyen
@longnt80
Jul 06 2017 05:59
@Giveback007 your anchor is at the top of the page so it will goes there
Bharath Kumar Reddy
@reddy-bharathkumar
Jul 06 2017 06:00
@Giveback007 try this instead of <a...
<section id="top">
</section>
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:00
@longnt80 it is bellow the header
Abubakar Sambo
@sastech
Jul 06 2017 06:00
@Giveback007 know what?
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:00
@reddy-bharathkumar oh that worked, thank you!!! but why
CamperBot
@camperbot
Jul 06 2017 06:00
giveback007 sends brownie points to @reddy-bharathkumar :sparkles: :thumbsup: :sparkles:
:cookie: 388 | @reddy-bharathkumar |http://www.freecodecamp.com/reddy-bharathkumar
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:01
do anchor elements reposition themselves somehow
Bharath Kumar Reddy
@reddy-bharathkumar
Jul 06 2017 06:01
you are anchoring to another anchor, I don't know how that works..
instead of section, I think you can also use div..
heroiczero
@heroiczero
Jul 06 2017 06:03
@Giveback007 maybe this will help http://help.typepad.com/anchor-tags.html just google anchoring within a page
gadzet
@gadzet
Jul 06 2017 06:07
Anyone could help me with the code approach ?
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:07

@heroiczero I understand anchor elements (at least I think I do), I just couldn't figure out why it would not function properly with smooth scrolling.

It might just be the implementation, but @reddy-bharathkumar already offered a good solution

i think the page will be divided in to sections || divs anyways so using them as scroll to points is good

Joseph
@revisualize
Jul 06 2017 06:10
@gadzet "code approach" ... What?
I just dropped in ... maybe I missed something.
Mai Thinh
@mthinh
Jul 06 2017 06:12
image.png
heroiczero
@heroiczero
Jul 06 2017 06:12
Mai Thinh
@mthinh
Jul 06 2017 06:12
Can sb pls explain me?
heroiczero
@heroiczero
Jul 06 2017 06:13
@mthinh could you link you codepen
heroiczero
@heroiczero
Jul 06 2017 06:13
@mthinh make sure you have a ?callback=?
Mai Thinh
@mthinh
Jul 06 2017 06:14
a callback? where pls ?
heroiczero
@heroiczero
Jul 06 2017 06:15
@mthinh in your var api = "https://api.darksky.net/forecast/c2967b46e19d21c46c7c787d3ddf92c6/"+lat+"," +long+ "?callback=?"
Long Nguyen
@longnt80
Jul 06 2017 06:15
@Giveback007 hey try this:
$('.slide-section').click(function(x) {
  var linkHref = $(this).attr('href');
  x.preventDefault();
  $('html, body').animate({
   scrollTop: $(linkHref).offset().top //- navHeight
  }, 1200,function() {
        window.location.hash = linkHref;
      });
 });
});
Joseph
@revisualize
Jul 06 2017 06:15
darksky TOS
@mthinh look... darksky TOS doesn't allow codepen
Mai Thinh
@mthinh
Jul 06 2017 06:17
@revisualize so which api i should use?
gadzet
@gadzet
Jul 06 2017 06:19
@revisualize
image.png
need to implement timeline
not sure what approach would be best
to generate the hours and the line
spans or svg
how to define sizes based on time
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:20
@longnt80 it does the same thing, the solution of replacing <a> with a <div> or other element works well
CallMeOrange
@EgnaroDev
Jul 06 2017 06:21
Can someone help me with random quote?
heroiczero
@heroiczero
Jul 06 2017 06:21
@mthinh :point_up: July 6, 2017 2:15 AM it works with a callback in for your link and/or making taking the dataType and format to be a jsonp in ajax
CallMeOrange
@EgnaroDev
Jul 06 2017 06:21
just loop part
Joseph
@revisualize
Jul 06 2017 06:21
@gadzet how has someone else done it?
heroiczero
@heroiczero
Jul 06 2017 06:22
@MCTwoDigitZero what do you mean loop part
CallMeOrange
@EgnaroDev
Jul 06 2017 06:22
Well to make it random
heroiczero
@heroiczero
Jul 06 2017 06:22
@MCTwoDigitZero Are you using your own quotes or an api?
CallMeOrange
@EgnaroDev
Jul 06 2017 06:22
I have this
my own quotes
  for (var i = 0; i < myQuote.length; i++) {
  var randomQuote = myQuote[i];
  }
  $("#MSG").on("click", function() {
    $(".message").html(randomQuote);
  });
heroiczero
@heroiczero
Jul 06 2017 06:22
@MCTwoDigitZero try using Math.random
CallMeOrange
@EgnaroDev
Jul 06 2017 06:23
oh my
gadzet
@gadzet
Jul 06 2017 06:23
@revisualize how should i know ?
CallMeOrange
@EgnaroDev
Jul 06 2017 06:23
@heroiczero Where do I use it? ... = Math.random(myQuote[i])?
heroiczero
@heroiczero
Jul 06 2017 06:24
@MCTwoDigitZero Personally, I would make an array of quotes and do math.random when you press a button or when the document is ready to access a quote from the array of quotes
CallMeOrange
@EgnaroDev
Jul 06 2017 06:25
I have an array of quotes
Long Nguyen
@longnt80
Jul 06 2017 06:26
@Giveback007 you're right, my bad
did you figure out why it didn't work with anchor?
wonder
@wonder2991
Jul 06 2017 06:26
array[Math.floor(Math.random()*array.length)];
CallMeOrange
@EgnaroDev
Jul 06 2017 06:26
Oh.. This is what I tried var randomQuote = myQuote[Math.floor(Math.random(i))];
Joseph
@revisualize
Jul 06 2017 06:27
@gadzet I only see a few images on that layout graphic
heroiczero
@heroiczero
Jul 06 2017 06:28
@MCTwoDigitZero :point_up: July 6, 2017 2:26 AM missing the length of array and you do not need the i
CallMeOrange
@EgnaroDev
Jul 06 2017 06:28
So I dont need for loop?
Joseph
@revisualize
Jul 06 2017 06:29
@gadzet I don't understand what you want to make an SVG.
heroiczero
@heroiczero
Jul 06 2017 06:29
@MCTwoDigitZero no you are trying to access a single quote randomly
Joseph
@revisualize
Jul 06 2017 06:29
@gadzet I wouldn't make any of the text into graphics.
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:29
@longnt80 no not sure, it's possible that anchor elements change their "top" value if they are not attached to anything specific, where as regular elements are more fixed
CallMeOrange
@EgnaroDev
Jul 06 2017 06:30
var randomQuote = myQuote[Math.floor(Math.random()*myQuote.length)];
Long Nguyen
@longnt80
Jul 06 2017 06:31
@Giveback007 no it's the scrollTop: $(linkHref).offset().top
this will scroll to the element with id of value linkHref
so if you give the anchor the id="top", it still works
CallMeOrange
@EgnaroDev
Jul 06 2017 06:31
@heroiczero If I dont need i, why do I need for loop?
heroiczero
@heroiczero
Jul 06 2017 06:32
@MCTwoDigitZero you do not need to loop
@MCTwoDigitZero just make it so when you press a button, you get a different quote
@MCTwoDigitZero When you first enter the page, you get a random quote
CallMeOrange
@EgnaroDev
Jul 06 2017 06:33
oh
gadzet
@gadzet
Jul 06 2017 06:34
@revisualize so should i just make a function generate timeline where i define start time and end time and a steper which is a minute and print spans which one span represents one minute define a width of minute length and in case case the now time is equal to that update the class name to show the orange line ?
@revisualize was thinking more of a react approach if i create <TimeLine/> component where i send the props of current time
Joseph
@revisualize
Jul 06 2017 06:36
@gadzet I think you need to slow down
@gadzet just make the thing with HTML and CSS first
CallMeOrange
@EgnaroDev
Jul 06 2017 06:37
@heroiczero I did console.log(randomQuote) it seems working but two quotes is not enough
Joseph
@revisualize
Jul 06 2017 06:38
@gadzet If you aren't able to make the thing with basic HTML and CSS ... How do you expect to make it with react and add <Timeline/> and other fancy shit?
heroiczero
@heroiczero
Jul 06 2017 06:38
@MCTwoDigitZero to make it cycle through lots of quotes i would use an api, such as https://quotesondesign.com/the-api/
Joseph
@revisualize
Jul 06 2017 06:39
@gadzet build a proof of concept first
CallMeOrange
@EgnaroDev
Jul 06 2017 06:39
I dont want to use an API yet
Joseph
@revisualize
Jul 06 2017 06:39
@gadzet Start out small.
heroiczero
@heroiczero
Jul 06 2017 06:39
@MCTwoDigitZero how long is your array with your quotes
CallMeOrange
@EgnaroDev
Jul 06 2017 06:40
For this I want to use only loop or Math.random, after this I will create another for Simpson etc... with some Api or JSON object
@heroiczero just 2, myQuote.length == 2
I will add more quotes
gadzet
@gadzet
Jul 06 2017 06:40
@revisualize but html and css what elements would be best to use for each minute ? span ? because at some point it has to be selected
heroiczero
@heroiczero
Jul 06 2017 06:40
@MCTwoDigitZero so it will only cycle between those two. try adding more and you will get more
Joseph
@revisualize
Jul 06 2017 06:41
@gadzet It is good to plan and think big picture... But, you need to have little goals.
CallMeOrange
@EgnaroDev
Jul 06 2017 06:41
yeah, I tested it should work if I add more
Brb adding more, will let you know if it is working
Joseph
@revisualize
Jul 06 2017 06:41
@gadzet span, div, li
gadzet
@gadzet
Jul 06 2017 06:41
@revisualize i am not a complete beginner i have already made http requests with react-redux and represented all the other stuff in the picture
@revisualize spa ?
iso
@iso1048
Jul 06 2017 06:42
hi, could someone please help me understand the following sentence about ajax: "Because the request is asynchronous, the rest of your code continues to execute while the request is being processed, so it's imperative that a callback be used to handle the response." What traits of a callback make it essential to be used to handle the response?
gadzet
@gadzet
Jul 06 2017 06:43
@revisualize so the div for the whole element and li for the hour or minutes ?
Joseph
@revisualize
Jul 06 2017 06:43
I don't know man.
@gadzet you're smarter than me. I don't know all that fancy shit.
gadzet
@gadzet
Jul 06 2017 06:45
@revisualize if i would be smarter i wouldnt ask
:D
Joseph
@revisualize
Jul 06 2017 06:45
I'm also loopy on meds. I just took two Oxycodone.
SaiChand Duppala
@saichandd
Jul 06 2017 06:45
@gothamknight when the request is sent, the job is to be done by server, i.e it should respond, in the mean time, you code will continue executing
CallMeOrange
@EgnaroDev
Jul 06 2017 06:47
@heroiczero Well now it is working, console.log(randomQuote) was the problem since randomQuote was not defined
@heroiczero @wonder2991 thanks
CamperBot
@camperbot
Jul 06 2017 06:47
mctwodigitzero sends brownie points to @heroiczero and @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 388 | @wonder2991 |http://www.freecodecamp.com/wonder2991
:star2: 1462 | @heroiczero |http://www.freecodecamp.com/heroiczero
SaiChand Duppala
@saichandd
Jul 06 2017 06:47
@gothamknight because callback is called at the end, the code will execute after you get the data from the server, or the varibles will be taken as undefined and code will keep on executing without proper results
jasonrest
@jasonrest
Jul 06 2017 06:48
anybody have any idea why this ajax call is not working? tried to output to the console the results. doesnt seem to connect.
https://codepen.io/jasonrest/pen/bRjGrM?editors=1011
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:50
@jasonrest Just add &callback=? at the end of your url
Dovydas Stirpeika
@Giveback007
Jul 06 2017 06:51
@longnt80 top "value" as in the where is the very top of the element in reference to the whole page
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:51
On my pen: https://codepen.io/jamesjpk123/pen/PjBNeN, I'm trying to make it so after 3 seconds it loads google.com. For some reason it is just loading a white page. can someone help me?
Relevant code:
window.onload = setTimeout(myFunction, 3000);

function myFunction() {
    window.location.assign("https://www.google.com")
}
CallMeOrange
@EgnaroDev
Jul 06 2017 06:52
If it loads white page, dont you need target="_blank"?
jasonrest
@jasonrest
Jul 06 2017 06:52
@SweetCodingInc ok i added that. I'm getting something back now in the console but not exactly what I was expecting. I was expecting search results. what do you make of this.
https://codepen.io/jasonrest/pen/bRjGrM?editors=1011
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:52
@MCTwoDigitZero wouldn't that open a new tab?
@MCTwoDigitZero I want the page to load inside the pen
@MCTwoDigitZero eventually, I want it instead of loading google.com, to load another pen that I create
Joseph
@revisualize
Jul 06 2017 06:53
that's gross
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:54
@jamesjpk123 Google doesn't let you embed itself in an iframe
Joseph
@revisualize
Jul 06 2017 06:54
don't do that
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:54
@SweetCodingInc would I be able to embed other websites? I just used Google as a placeholder
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:54
do it locally, because codepen loads your page in iframe
iso
@iso1048
Jul 06 2017 06:54
@imradioactive that helps. thanks
CamperBot
@camperbot
Jul 06 2017 06:54
gothamknight sends brownie points to @imradioactive :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @imradioactive |http://www.freecodecamp.com/imradioactive
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:54
@jamesjpk123 Give it a try
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:54
@SweetCodingInc ok
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:55
@jasonrest Check your response object. It contains a subobject called pages
Bomee
@Bomulacious
Jul 06 2017 06:55

function bouncer(arr) {
return arr.filter(Boolean);
}
explanation says "The Array.prototype.filter method expects a function that returns a Boolean value which takes a single argument and returns true for truthy value or false for falsy value. Hence we pass the built-in Boolean function."

my question is, why wouldn't it return false had the value been falsy??

Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:55
it contains results
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:55
jasonrest
@jasonrest
Jul 06 2017 06:55
@SweetCodingInc hmmmmm ok i guess i have to isolate pages. extract. ok thanks.
CamperBot
@camperbot
Jul 06 2017 06:55
jasonrest sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 76 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:56
@jamesjpk123 Yeah... Then may be, it's codepen that doesn't let you embed other sites in its container
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:56
@SweetCodingInc I'm going to try jsfiddle
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:56
@Bomulacious It does return false for falsy value
@jamesjpk123 if you take a look at bottom right corner of codepen, there is an option to export your pen
export it and download it on your machine and run that locally
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:57
@SweetCodingInc oh sweet!
SaiChand Duppala
@saichandd
Jul 06 2017 06:57
@jamesjpk123 jsfiddle might not work too, try doing it locally
Bomee
@Bomulacious
Jul 06 2017 06:57
@SweetCodingInc then how can this code be a solution to the challenge "Remove all falsy values from an array."?
CallMeOrange
@EgnaroDev
Jul 06 2017 06:57
A question... for random quote machine, how do I have the button stay in one spot when quote loads?
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:58
@Bomulacious Because you're using .filter Filter will drop all the elements that return you false when you run the callback function (Boolean in this case) returns false for current element
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:58
@SweetCodingInc + @imradioactive I have notepad++ as my code editor, and a vanilla version of ATOM. Is this enough to run locally?
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:58
@jamesjpk123 when you download, just double click index.html
and it will run
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 06:59
ok
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:59
for editing, Atom sounds good
SaiChand Duppala
@saichandd
Jul 06 2017 06:59
@MCTwoDigitZero you can give some more height to the quote box, so that the height doesnt fluctuate for every quote
@jamesjpk123 just atom and browser
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 06:59

however, I'd recommend installing a stand alone file server..

Do npm install -g http-server

then cd to the location where you've downloaded your pen.
in command prompt/terminal
and say http-server
Bomee
@Bomulacious
Jul 06 2017 07:00
thank you! @SweetCodingInc
CamperBot
@camperbot
Jul 06 2017 07:00
bomulacious sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 77 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
CallMeOrange
@EgnaroDev
Jul 06 2017 07:00
@imradioactive what if quote is too big?
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:00
then open your chrome and hit http://localhost:8080
@Bomulacious :+1:
SaiChand Duppala
@saichandd
Jul 06 2017 07:00
@MCTwoDigitZero yeah, give a big enough height so that any quote should fit
CallMeOrange
@EgnaroDev
Jul 06 2017 07:00
I'll try
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 07:01
Cool! it works @imradioactive and @SweetCodingInc when I run it locally. However, It would be a lot more convenient to have it on CodePen, since I don't have a domain name or website hosting for hosting html and js. Do you know of any way to make it "legal" in CodePen?
CallMeOrange
@EgnaroDev
Jul 06 2017 07:01
@imradioactive sorry, margin-top or height?
SaiChand Duppala
@saichandd
Jul 06 2017 07:01
@jamesjpk123 I guess, they wont allow it for some security resons
@MCTwoDigitZero height of the element into which you are pulling the quote
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:01
Just a note: Using Boolean as a callback function causes coercion to happen twice. You're better off using this approach
function bouncer(arr) {
  return arr.filter(x => x);
}

// OR in normal js (ES5)

function bouncer(arr) {
  return arr.filter(function(x){
    return x;
  });
}
@Bomulacious
CallMeOrange
@EgnaroDev
Jul 06 2017 07:02
@imradioactive oh I see
That element where quote will show up
SaiChand Duppala
@saichandd
Jul 06 2017 07:02
@MCTwoDigitZero yeahh
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:02
@jamesjpk123 : Nope! Not possible in codepen. Becuase whatever output you get is itself embedded in codepen page
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 07:03
I've seen a pen, https://codepen.io/mikemang/pen/zoLEpq that does this some way, but I don't know how. I am trying to mimic the pen's way of displaying a new pen at the end of each level @SweetCodingInc and @imradioactive
Bomee
@Bomulacious
Jul 06 2017 07:04
@SweetCodingInc what is the "first abnormal" js called?
SaiChand Duppala
@saichandd
Jul 06 2017 07:04
@jamesjpk123 that pen isnt working for me
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:04
@jamesjpk123 I assume that's possible because you're redirecting to another thing that belongs to codepen
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 07:05
@imradioactive it doesn't work in the embed, but it works on the pen's page
CallMeOrange
@EgnaroDev
Jul 06 2017 07:05
@imradioactive it works, didnt know it work like that way thanks
CamperBot
@camperbot
Jul 06 2017 07:05
mctwodigitzero sends brownie points to @imradioactive :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @imradioactive |http://www.freecodecamp.com/imradioactive
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:05
@Bomulacious What do you mean "first abnormal"?
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 07:05
@SweetCodingInc I guess ill try with that link
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:05
You mean this part .filter(x => x); ? @Bomulacious
SaiChand Duppala
@saichandd
Jul 06 2017 07:05
@MCTwoDigitZero its just showing loading for me, weird
Bomee
@Bomulacious
Jul 06 2017 07:05
@SweetCodingInc yes
@SweetCodingInc I've never seen it
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:06
@Bomulacious It's ES6 syntax
SaiChand Duppala
@saichandd
Jul 06 2017 07:06
@Bomulacious thats ES6
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:06
In my webpage , I want to load all the images first then use them as background as per the situation . How can I do that ??, please help ..
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:06
x => x ( called as fat Arrow Function) is just another way of saying
function(x) {
  return x;
}
It's equivalent, but not entirely equal
James Patrick Kerrane
@jamesjpk123
Jul 06 2017 07:06
@SweetCodingInc, @imradioactive, and @MCTwoDigitZero it works! Thank you for all your help!
CamperBot
@camperbot
Jul 06 2017 07:06
jamesjpk123 sends brownie points to @sweetcodinginc and @imradioactive and @mctwodigitzero :sparkles: :thumbsup: :sparkles:
:cookie: 78 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
:cookie: 447 | @mctwodigitzero |http://www.freecodecamp.com/mctwodigitzero
:cookie: 308 | @imradioactive |http://www.freecodecamp.com/imradioactive
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:06
@jamesjpk123 :+1:
Bomee
@Bomulacious
Jul 06 2017 07:07
@imradioactive @SweetCodingInc I see, thanks!
CamperBot
@camperbot
Jul 06 2017 07:07
bomulacious sends brownie points to @imradioactive and @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: bomulacious already gave sweetcodinginc points
:cookie: 309 | @imradioactive |http://www.freecodecamp.com/imradioactive
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:07
In my webpage , I want to load all the images first then use them as background as per the situation . How can I do that ??, please help .. Can Anyone help ??????????/
SaiChand Duppala
@saichandd
Jul 06 2017 07:07
@Bomulacious ES6 makes the code short
@Gr8ayu the page loads the images as per requirement
Bomee
@Bomulacious
Jul 06 2017 07:08
@imradioactive aha, looks like it :)
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:08
@imradioactive : Making code short is just one side effect of fat arrow function. Most important thing is the value of this in normal function function and fat arrow function
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:09
@imradioactive I want to preload images , so that they don't slow down
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:09
Fat Arrow Function doesn't spawn it's own isolate scope.
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:09
@imradioactive like keeping in cache
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:09
@Gr8ayu You could load them using ajax, and keep your entire page hidden until all the images are loaded
CallMeOrange
@EgnaroDev
Jul 06 2017 07:09
lol Fat Arrow
SaiChand Duppala
@saichandd
Jul 06 2017 07:10
@SweetCodingInc ohh, I thought it just makes the code short and easier to read thanks
CamperBot
@camperbot
Jul 06 2017 07:10
:cookie: 79 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
imradioactive sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Jul 06 2017 07:10
Fat Arrow => and skinny arrow ->
six pack arrow
===
===
===
>
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:10
Yo! Isn't it ironic that something called fat arrow actually makes more space by having to type less number of characters? lol
CallMeOrange
@EgnaroDev
Jul 06 2017 07:10
@SweetCodingInc yeah
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:11
@SweetCodingInc @imradioactive see this https://codepen.io/gr8ayu/pen/rwKEOR/?editors=0111 , on clicking red button , card images are not changing
jorlee92
@jorlee92
Jul 06 2017 07:12
Hey, can anybody tell me why this code runs when you load the page? https://codepen.io/jorlee92/pen/OgZzZP
SaiChand Duppala
@saichandd
Jul 06 2017 07:12
@Gr8ayu you can make a div, and make its display none after the a certain time, you need to use some javascipt
@MCTwoDigitZero did that height thing work?
CallMeOrange
@EgnaroDev
Jul 06 2017 07:12
@imradioactive Didnt I tell you lol
@imradioactive it works, didnt know it work like that way thanks
CamperBot
@camperbot
Jul 06 2017 07:12
mctwodigitzero sends brownie points to @imradioactive :sparkles: :thumbsup: :sparkles:
:warning: mctwodigitzero already gave imradioactive points
SaiChand Duppala
@saichandd
Jul 06 2017 07:13
@MCTwoDigitZero i forgot :smile:
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:14
@jorlee92 : Because you're calling that function when you assign it as an event handler
$('#random-quote-button').on('click', append_quote());
It should be
$('#random-quote-button').on('click', append_quote);
Side effect of first approach is it will only work once
when you click the button again, it won't
jorlee92
@jorlee92
Jul 06 2017 07:15
@SweetCodingInc Thanks! That did it
CamperBot
@camperbot
Jul 06 2017 07:15
jorlee92 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 80 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
jorlee92
@jorlee92
Jul 06 2017 07:15
Where can I read more to learn how that works
So I can know why that happened? I spent like 20-30 minutes looking around
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:16
These are basics. :) Very unlikely to find documentation for it
because the .click docs say, it expects event name and function
so 2nd parameter should be a Function
but when you do something like what you had done initially, it doesn't work
jorlee92
@jorlee92
Jul 06 2017 07:17
But I dont understand why append_quote is a function
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:17
because
jorlee92
@jorlee92
Jul 06 2017 07:17
but append_quote() isnt a function
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:17
when you do
$('#random-quote-button').on('click', append_quote());
what it really means is
hey, I have an element that has Id random-quote-button
I want to assign it a click event handler
and the handler is append_quote()
now when you put () after a function name, it means you're calling a function
so your click handler in this case will be whatever value your append_quote returns
if it doesn't return a function, then your click handler can't call it
becuase it is not a function
Nitin Sahu
@globefire
Jul 06 2017 07:19

function largestOfFour(arr) {
  // You can do this!
  var a = [];
  var b = [];
  var c = [];
  for(var i = 0; i < arr.length; i++){
    a = arr[i];
    b = a[0];
    for(var j = 0; j < a.length; j++){
      if (b <= a[j]){
        b = a[j];
      }
    }
    c = b;
  }
  return c;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
can someone tell me what is wr0ong in here ? to find largest nos. from each sub array
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:20
but when you use append_quote instead append_quote(), you're actually assigning a function for click event handling
hope that is clear
jorlee92
@jorlee92
Jul 06 2017 07:20
@SweetCodingInc Thanks, I will have to put that in a notebook of things to remember. Also what would have happened if append_quote() returned get_quote ?
CamperBot
@camperbot
Jul 06 2017 07:20
jorlee92 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: jorlee92 already gave sweetcodinginc points
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:20
@jorlee92 Now you're thinking! That would do!
Nitin Sahu
@globefire
Jul 06 2017 07:22
anyone there to help me ?
alpox
@alpox
Jul 06 2017 07:22
@globefire you dont need the variable c. B would absolutely do it. Also, b is no array - this is no error, but it can be confusing if you initialize it as such and only assign numbers later. Then, your b will always get the smallest value available, so i believe you have to swap your comparison
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:22
You'd have to miodify your get_quote in such a way that it appends your random quote to your dom
$("#random-quote").append("<p>" + quote + "</p>");
instead of return statement
and in your append quote
function append_quote(){
  return get_quote;
  //$("#random-quote").append(get_quote());

}
@globefire instead of c=b you need to do c.push(b);
and everything else is good
jorlee92
@jorlee92
Jul 06 2017 07:24
Interesting, so kinda works like a pointer to a function. And I was pointing it at the output of a function instead?
CallMeOrange
@EgnaroDev
Jul 06 2017 07:24
Its not completed yet but what do you think?
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:25
@jorlee92 Everything in JS, except for primitives, is a pointer ;)
Its all call by reference and pass by reference
@jorlee92 Correct, you were making the output to be a function...
jorlee92
@jorlee92
Jul 06 2017 07:25
@SweetCodingInc Well allright, I need to write this down
Nitin Sahu
@globefire
Jul 06 2017 07:26
                   @alpox  no need of swapping man i just made a minor change and guess what the code succeeded
Himujjal Upadhyaya
@Himujjal
Jul 06 2017 07:26
What's up with beta .freecodecamp.com ? Are the certificates still valid?
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:26
but your function was returning undefined (which isnt a function) .
Viktor Tiutiun
@vittorioVT
Jul 06 2017 07:26
@globefire put cycle for (var= j...) inside the cycle for i
alpox
@alpox
Jul 06 2017 07:26
@globefire Correction - sry i didn't remember the challenge right.
You do need c, but not as a number. You assign b to it - which is a number, so c does become a number instead of staying an array to which you push the result of b
Himujjal Upadhyaya
@Himujjal
Jul 06 2017 07:26
I seem to like this new curriculum.
Nitin Sahu
@globefire
Jul 06 2017 07:26
i did it
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:26
@globefire :+1:
CallMeOrange
@EgnaroDev
Jul 06 2017 07:27
@Himujjal Yes until Progress will be deleted during the time fCC getting merged with beta fCC
SaiChand Duppala
@saichandd
Jul 06 2017 07:27
@MCTwoDigitZero i'd say give a padding to that transparent white thing
Nitin Sahu
@globefire
Jul 06 2017 07:27

function largestOfFour(arr) {
  // You can do this!
  var a = [];
  var b;
  var c = [];
  var k = 0;
  for(var i = 0; i < arr.length; i++){
    a = arr[i];
    b = a[0];
    for(var j = 0; j < a.length; j++){
      if (b <= a[j]){
        b = a[j];
      }
    }
    c[k] = b;
    k++;
  }
  return c;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
this one succeeded
CallMeOrange
@EgnaroDev
Jul 06 2017 07:27
@imradioactive what for? responsive?
jorlee92
@jorlee92
Jul 06 2017 07:28
@SweetCodingInc Cool, thanks for the help
CamperBot
@camperbot
Jul 06 2017 07:28
jorlee92 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: jorlee92 already gave sweetcodinginc points
CallMeOrange
@EgnaroDev
Jul 06 2017 07:28
@Himujjal So I'd say these certificates might be available until November
SaiChand Duppala
@saichandd
Jul 06 2017 07:28
@MCTwoDigitZero no, just to look good
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:28

@globefire

Instead of

c[k] = b;
k++;

You could use

c[k++] = b;

or much cleaner way is

c.push(b);
@jorlee92 :+1:
CallMeOrange
@EgnaroDev
Jul 06 2017 07:28
@imradioactive what changes will it make? I forgot what padding was... like margin-top, right etc..?
Himujjal Upadhyaya
@Himujjal
Jul 06 2017 07:29
@MCTwoDigitZero So, The certificates that I earn there won't be valid after the merge? Because I really like how things are presented there. I am big fan of React and the challenges there are awesome.
CallMeOrange
@EgnaroDev
Jul 06 2017 07:29
@Himujjal Im not sure, Im saying that they will be available until November
alpox
@alpox
Jul 06 2017 07:29
@jorlee92 Yes, and to get the output of the function, the function has to run :D so your code of the function did run right when you wanted to assign it to the eventhandler
CallMeOrange
@EgnaroDev
Jul 06 2017 07:29
You could wait after merged with fCC then earn these certs @Himujjal
SaiChand Duppala
@saichandd
Jul 06 2017 07:30
@MCTwoDigitZero put it and check, it'll make the words come inside, instead of sticking to the wall
CallMeOrange
@EgnaroDev
Jul 06 2017 07:31
@imradioactive add this? padding: 10px; to element where that box come from?
or the quote
@imradioactive oh now I see what you mean by "words come inside"
SaiChand Duppala
@saichandd
Jul 06 2017 07:32
@MCTwoDigitZero yeah add it to box class
CallMeOrange
@EgnaroDev
Jul 06 2017 07:32
Bro that is what im looking for, thanks
SaiChand Duppala
@saichandd
Jul 06 2017 07:32
:thumbsup:
CallMeOrange
@EgnaroDev
Jul 06 2017 07:33
Now whats left is to add more quotes and making it responsive..
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:35
@alpox can we use object using index ??
@alpox like console.log(myObj[1]); ??
Dan Couper
@DanCouper
Jul 06 2017 07:36
Objects don't have order
So no, you access properties by name, not index
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:37
@DanCouper that means I can't ??
alpox
@alpox
Jul 06 2017 07:37
@Gr8ayu Of course. Objects can take any keys and you can refer with the indexer to the keys.
Mai Thinh
@mthinh
Jul 06 2017 07:37
image.png
how i get back to F degree after click pls?
Dan Couper
@DanCouper
Jul 06 2017 07:38
They aren't ordered though, you would need to add an index field. They aren't designed as iterable structures
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:38
@alpox but object is like myObj={name:"aa",age:12};
alpox
@alpox
Jul 06 2017 07:38

@Gr8ayu You can, its just usually not done with increasing numbers. I mean you cannot access an object like:

var obj = { foo: "bar" }

With obj[0]. Obj has no key 0 defined.

@Gr8ayu You could access the object like that if you had it like:
var obj = { 0: "foo" }
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:38
@alpox @DanCouper ok thank u
CamperBot
@camperbot
Jul 06 2017 07:38
gr8ayu sends brownie points to @alpox and @dancouper :sparkles: :thumbsup: :sparkles:
:star2: 1226 | @alpox |http://www.freecodecamp.com/alpox
:cookie: 833 | @dancouper |http://www.freecodecamp.com/dancouper
alpox
@alpox
Jul 06 2017 07:39
@Gr8ayu In that case you have to access your object through the keyname - myObj.name or myObj.age or myObj["name"] or myObj["age"]
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:40
@alpox @DanCouper suppose I have an object of 100 values and I want to print them separately , how can I do that ??
alpox
@alpox
Jul 06 2017 07:40
@Gr8ayu What you can do, is first get all the keys out of the object with Object.keys(myObj) Which gives you the array ["name", "age"]. You can index on that one with 0 or 1 to get the key, through which you can access the specific value in the object
Dan Couper
@DanCouper
Jul 06 2017 07:40
@Gr8ayu these are exactly the same {name:'aa',age:12}, {age:12,name:'aa'}
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:41
@alpox Ok , got it , that what I was looking for :smile: :smile:
alpox
@alpox
Jul 06 2017 07:41
Or you can loop over all the keys with
for(var key in myObj) {
    var value = myObj[key];
    ....
}
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:41
@Gr8ayu these are exactly the same {name:'aa',age:12}, {age:12,name:'aa'} @DanCouper why so ??
alpox
@alpox
Jul 06 2017 07:41
@Gr8ayu As we already stated, an object doesn't have any order
So the order in which you put elements in an object does not matter at all
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:42
hmm
Tai Jones
@taiJones00
Jul 06 2017 07:42
Anybody good with react?
Dovydas Stirpeika
@Giveback007
Jul 06 2017 07:43

I'm working on my first client website
https://codepen.io/giveback007/full/awjmdB/

any input would be apreciated

Ayush Kumar
@Gr8ayu
Jul 06 2017 07:43
@alpox keys=Object.keys(MyObj); like this I have to write?
alpox
@alpox
Jul 06 2017 07:43
@taiJones00 ~
Whut why did it become a snail
@Gr8ayu you would best initialize the variable keys. Also, i think your variable is in camel-case?
@Gr8ayu var keys = Object.keys(myObj)
jasonrest
@jasonrest
Jul 06 2017 07:46
what is the proper way to extract the pages object? I thought it would be data.pages but that is not working.
https://codepen.io/jasonrest/pen/bRjGrM?editors=1011
alpox
@alpox
Jul 06 2017 07:49
@jasonrest data.query.pages - you can inspect the object in your console to get the path right
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:49
@alpox how can I make all image appear at once on clicking red button ?? https://codepen.io/gr8ayu/pen/rwKEOR/?editors=0011
alpox
@alpox
Jul 06 2017 07:50
@Gr8ayu You'd have to preload them - they should be loaded when the cards turn
jasonrest
@jasonrest
Jul 06 2017 07:50
@alpox sorry if I could ask for an example on inspecting the object.
alpox
@alpox
Jul 06 2017 07:50
@Gr8ayu So your best bet is to create one pseudo image element for each of the cards, wait for them to be loaded, and then go on using them
@jasonrest Well you already printed it to the console. Could you see it there?
Then you just have to look at the nesting.
{
    query: {
        pages: ....
    }
}
Ayush Kumar
@Gr8ayu
Jul 06 2017 07:51
```
var keys=Object.keys(cardUrl);
for(i=0;i<keys.length;i++){
$("#preLoadImage").attr("src","https://www.dropbox.com/s/"+keys[i]+"?raw=1");
}``` I have tried  to load all Images in main() function @alpox 
jasonrest
@jasonrest
Jul 06 2017 07:52
yes but it wasnt what i was expecting. @alpox so this format. data.query."" is across the board in JSON or just this instance.
alpox
@alpox
Jul 06 2017 07:54
@Gr8ayu 1. its cardUrl[keys[i]] and 2. you change the url of the element already before the image was ever loaded. This would be an asynchronous task
@jasonrest Just in this instance
@jasonrest Every format is a different one
jasonrest
@jasonrest
Jul 06 2017 07:55
@alpox Thanks. codepen said it was too many results to post so doing it locally
CamperBot
@camperbot
Jul 06 2017 07:55
jasonrest sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1227 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Jul 06 2017 07:55
The documentation of the api usually tells you what layout there is
jasonrest
@jasonrest
Jul 06 2017 07:56
@alpox right ive been noticing that from one project to the next, not always the same.
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:57
@jasonrest You can hit F12 and see what is being actually logged on the console
the codepen console don't have much capacity
jasonrest
@jasonrest
Jul 06 2017 07:58
@SweetCodingInc yeah i dont particularly care for it. and it teaches bad practice IMO but who am I. so i do double work, code locally and put it on codepen when i need help here or ready to submit.
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 07:59
Sounds good
Dan Couper
@DanCouper
Jul 06 2017 08:42
@Gr8ayu can you show more code? And putting aside the issue you're having syntax-wise, can you explain what you're doing with this preloading? ie exactly what and why you're trying to preload images. + At the minute you're relying on jQuery, so you need that loaded first: if it is at the end of the body rather than the head, what you're a doing is irrelevant because I it would load everything first anyway. And saying you're doing it as part of your main function suggests that function does other things as well, things that won't matter until the page is loaded.
Hemakshi Sachdev
@hemakshis
Jul 06 2017 09:07
Hey guyss I'm really stuck in this Spinal Tap Case challenge..I am not able to clear the 4th text case
function upperToLowerCase(match,offset,string) {
  return (offset ? '-' : '') + match.toLowerCase();
}

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  str = str.replace(/ /g,"");
  str = str.replace(/_/g,"");

  str = str.replace(/[A-Z]/g,upperToLowerCase);
  if(str[0] === '-'){
    var atr = str.replace(/^-/,"");
    return atr;
  }
  return str;
}

spinalCase('This Is Spinal Tap');
please help
SaiChand Duppala
@saichandd
Jul 06 2017 09:22
@hemakshis str = str.replace(/ /g,""); lines is making you miss some the cases in which there is a small letter after space
Hemakshi Sachdev
@hemakshis
Jul 06 2017 09:26
@imradioactive yes but removing that, also does not helps
other cases give wrong ans
SaiChand Duppala
@saichandd
Jul 06 2017 09:28
one way is to use str = str.replace(/ /g,"-"); and then remove the doubles dashes later
@hemakshis i did it that way i
wonder
@wonder2991
Jul 06 2017 09:30
that's a one line challenge. all you need is regex , replace and toLowerCase
Ogundele Olumide
@Lumexralph
Jul 06 2017 09:38
@wonder2991 when you say one line challenge, it's subjective I think, readability over elegance, what do you think?
Hemakshi Sachdev
@hemakshis
Jul 06 2017 09:47
@imradioactive done :+1: thanks :)
CamperBot
@camperbot
Jul 06 2017 09:47
hemakshis sends brownie points to @imradioactive :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @imradioactive |http://www.freecodecamp.com/imradioactive
shivam gupta
@shivamg11000
Jul 06 2017 09:47
can anybody explaing the Component.isProps to me in this
Javi Ferré
@CurrentDate
Jul 06 2017 09:50
Hi, i have some problems with .show .hide method, I'm trying to hide and show some divs with buttons, but im getting some weird behaviour, anyone could check this codepen?
Dan Couper
@DanCouper
Jul 06 2017 09:51
@shivamg11000 what do you mean by Component.isProps?
wonder
@wonder2991
Jul 06 2017 09:51
@Lumexralph yeah. i guess you're right
shivam gupta
@shivamg11000
Jul 06 2017 09:51
@DanCouper see the pen
I mean Component.propTypes
Dan Couper
@DanCouper
Jul 06 2017 09:52
ah, it's typechecking
it says name is a string and it is required
shivam gupta
@shivamg11000
Jul 06 2017 09:55
@DanCouper but I have set the proptypes for name to string and I am passing an array, then why it is working
Dan Couper
@DanCouper
Jul 06 2017 09:57
you haven't imported the proptypes library anywhere, so you're just defining an object, so no error
shivam gupta
@shivamg11000
Jul 06 2017 09:57
@DanCouper what is that
Dan Couper
@DanCouper
Jul 06 2017 09:57
as in PropTypes is a seperate module, like ReactDOM and React are modules
you have both of those
but you don't have proptypes
Note: React.PropTypes is deprecated as of React v15.5. Please use the prop-types library instead.
shivam gupta
@shivamg11000
Jul 06 2017 09:59
That means PropTypes is no longer
Dan Couper
@DanCouper
Jul 06 2017 10:00
It's just seperate, you don't automatically get it with React, same as how you don't automatically get ReactDOM, you need to include the library
shivam gupta
@shivamg11000
Jul 06 2017 10:03
@DanCouper I gave it script https://unpkg.com/prop-types/prop-types.js
its not working
alpox
@alpox
Jul 06 2017 10:04
@shivamg11000 You will have to use the npm package to make it work with webpack
shivam gupta
@shivamg11000
Jul 06 2017 10:04
@alpox on codepen
alpox
@alpox
Jul 06 2017 10:06
@shivamg11000 Ah alright
Dan Couper
@DanCouper
Jul 06 2017 10:07
yeah, I don't think this will work on CodePen, it's designed to be run when compiling files really. You need to import the PropTypes object, which CodePen won't like. You could just use an earlier version of React (15.4 or lower)
alpox
@alpox
Jul 06 2017 10:07

@shivamg11000 Just use

Foo.propTypes = {
  name : PropTypes.string.isRequired
};

then

alpox
@alpox
Jul 06 2017 10:20
I just encountered that it works with the react/react-dom libraries you import @DanCouper but not with the versions @shivamg11000 imports. Taking the same library links for react/react-dom over, proptypes start working.
I'm not sure what causes this ^^
Dan Couper
@DanCouper
Jul 06 2017 10:25
15.4.0 vs 15.4.5
should be
//cdnjs.cloudflare.com/ajax/libs/react/15.4.0/react.js
//cdnjs.cloudflare.com/ajax/libs/react/15.4.0/react-dom.js
should work fine once that's changed
I get the error message about the prop in the console after that
note I changed the name of the property, did is as a matter of course, so not sure if it'll actually have any effect, but name is an actual HTML attribute
gadzet
@gadzet
Jul 06 2017 10:43
var Hello = React.createClass({
  render: function() {
  let arr = [];
  function generateTimelineArray(start, = 1499162400 end = 1499248800, step = 60) {
    for(let i = start; i < end;i+=step) {
      arr.push(i);
    }
    console.log(arr);
  }
    return 
    <div>Hello {this.props.name}
    {generateTimelineArray()}
    </div>;
  }
});

ReactDOM.render(
  <Hello name="World" />,
  document.getElementById('container')
);
why do i get unexpected token for the function generateTimeLineArray ?
Markus Kiili
@Masd925
Jul 06 2017 10:48
@gadzet Maybe (start, = 1499162400 end = 1499248800, step = 60) is wrong.
gadzet
@gadzet
Jul 06 2017 10:58
class App extends Component {

  render() {
  let arr = [];
  function generateTimelineArray(start = 1499162400, end = 1499248800, step = 60) {
    for(let i = start; i < end;i+=step) {
      arr.push(i);
  }
  console.log(arr);



    return (
      <div className="App">
aaaa
      </div>
    );
  }
}

export default App;
You where right @Masd925 thanks, but why is it failing on export default now, where should the function and let declarations be ?
CamperBot
@camperbot
Jul 06 2017 10:58
gadzet sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4287 | @masd925 |http://www.freecodecamp.com/masd925
crbentley01
@crbentley01
Jul 06 2017 11:02
Hey guys, could I get a hand with my weather app, please? I've created global variables (lat and long) to be updated as my coordinates but they aren't changing outside of the geolocation function..? https://codepen.io/crbentley01/pen/PjaMMY?editors=0011
Stephen James
@sjames1958gm
Jul 06 2017 11:23
@crbentley01 get location is asynchronous, which means you have to call the getJSON from the same execution context as setting the lat/lon
This means putting getJSON in the callback, or into a function that you call from within the get position callback.
Jayne
@jayne88
Jul 06 2017 11:24
Hi Guys! So I am working on the profile lookup section, but the code is rather temperamental. It works sometimes. I had to get some help from google as I keep forgetting the syntax order of for loops. Is there any way of practicing/remembering that at all? Here is my code for that challenge:

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName === firstName){
if (contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such contact";
}
}return "No such property";

// Only change code above this line
}

}
// Change these values to test your function
lookUpProfile("Akira", "lastName");

Stephen James
@sjames1958gm
Jul 06 2017 11:26
@jayne88 Why would the else for hasOwnProperty be no such contact and not no such property?
You for loop syntax is fine. Practice is what it will take to remember
@jayne88 Also, consider that you cannot successfully return no such contact until all the contacts have been checked
Jayne
@jayne88
Jul 06 2017 11:28
@sjames1958gm Yeah I just noticed I had that in the wrong order, I've changed that now. I have an unmatched curly brace too which I am figuring out where that unmatch is coming from. Okay cool, thank you! I keep resetting the code in order to remember the syntax so will keep working on that. Yes that's true, thank you again :D
CamperBot
@camperbot
Jul 06 2017 11:28
jayne88 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7997 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
crbentley01
@crbentley01
Jul 06 2017 11:29
@sjames1958gm Thank you!
CamperBot
@camperbot
Jul 06 2017 11:29
crbentley01 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7998 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 06 2017 11:29
@jayne88 :+1:
@crbentley01 yw
shivam gupta
@shivamg11000
Jul 06 2017 11:31
cbot
CamperBot
@camperbot
Jul 06 2017 11:31
you called?
Victor Popescu
@VicPopescu
Jul 06 2017 11:37
@camperbot too smart for your own good :D
Ken Haduch
@khaduch
Jul 06 2017 11:39
@jayne88 - just a little help - - for code posting information see https://forum.freecodecamp.com/t/markdown-code-formatting/18391 - basically, use backticks, like ``` on a line all alone at the start and end of your code block. Also, you can edit your posts for a few minutes after you make them. And when you are posting code for this challenge or others like it, it is not necessary to post all of the "data" like the contacts list, since that is always the same. It keeps the chat from getting too busy.
Jayne
@jayne88
Jul 06 2017 11:43
@khaduch Thank you for your advice, I'll try to make sure I do that from now on. Appreciate all the help I am getting :D
CamperBot
@camperbot
Jul 06 2017 11:43
jayne88 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3072 | @khaduch |http://www.freecodecamp.com/khaduch
mixa1901
@mixa1901
Jul 06 2017 12:02
hi guys. Challenge - "Spinal Tap Case". Why does it show infinite loop in this code??? and how can i fix it ?

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
var firStr = str.replace(/\s/gi, "").replace(/[_]/gi, "").split("");
var free = [];


  for(var i =0; i < firStr.length; i++) {
  if (firStr[i] == firStr[i].toUpperCase()) {
 firStr.splice(i-1, 0, "-");
}
}

  return firStr;
}

spinalCase('allThe-small Things');
Ogundele Olumide
@Lumexralph
Jul 06 2017 12:04
@mixa1901 it's not a good idea to mutate an array you're iterating or looping through, you can create a copy of that array and manipulate that
@mixa1901 firStr.splice(i-1, 0, "-"); this is the cause, you can create a copy of firstStr array using slice
Stephen James
@sjames1958gm
Jul 06 2017 12:07
@mixa1901 If you are going to splice, you need to realize you are adding a character before the index i and need to adjust i or you
will be looking at the same character over and over again
mixa1901
@mixa1901
Jul 06 2017 12:09
@Lumexralph how slice can help? what should i slice ?
@sjames1958gm what method except splice can add element to array from particular indexx ?
Stephen James
@sjames1958gm
Jul 06 2017 12:11
@mixa1901 you can use splice, just realize you may have to adjust i when that happens
Nick Janne
@njanne19
Jul 06 2017 12:13
Can anyone tell me why when I hit delete recipe on my project it deletes the opposite item?
https://codepen.io/njanne19/pen/zzaVjx?editors=0110
mixa1901
@mixa1901
Jul 06 2017 12:14
@sjames1958gm ty
CamperBot
@camperbot
Jul 06 2017 12:14
mixa1901 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7999 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Gus
@Guscoder
Jul 06 2017 12:16
Looking for a little help on this..not sure what is wrong. keeps throwing an error "cannot read property of length undefined"
Nick Janne
@njanne19
Jul 06 2017 12:16
@Guscoder show me your code I can take a look
Gus
@Guscoder
Jul 06 2017 12:17

function filteredArray(arr, elem) {
  let newArr = [];
  // change code below this line
  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr[i].length; j++) {
      if (arr[i][j] === elem) {
       arr.splice(i, 1); 
      }
    }    
  }
  // change code above this line
  return newArr;
}

// change code here to test different cases:
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
Supposed to remove any of the sub-arrays that contain the elem arg
Marianissimus
@Marianissimus
Jul 06 2017 12:18
@Guscoder why not indexOf? should be simpler to set-up. just my 2 cents
Dan Couper
@DanCouper
Jul 06 2017 12:19
just glancing at the code, you're deleting an array while youre iterating through it, so I assume it'll be trying to get the length for something that doesn't exist
Marianissimus
@Marianissimus
Jul 06 2017 12:21
if ( arr[i].indexOf(elem) !== -1) or something like this
Dan Couper
@DanCouper
Jul 06 2017 12:21
yeah, that would fix it. But if sticking with splice, that arr.splice(i, 1); cannot be inside the inner loop
wonder
@wonder2991
Jul 06 2017 12:22
yeah. look at the error in your console.
Nick Janne
@njanne19
Jul 06 2017 12:25
  deleteStatefulRecipes(food) {
    var index;
    for (var i = 0; i<this.state.recipes.length; i++) {
      if (this.state.recipes[i].name == food) {
        index = i;
        var newArr = this.state.recipes.splice(index, 1);
        localStorage.recipes = JSON.stringify(newArr);
        this.setState({
        recipes: newArr
        });
        break;
      }
    }
  }
Anyone have ideas as to why this is deleting the wrong index
Dan Couper
@DanCouper
Jul 06 2017 12:26
var newArr = this.state.recipes.splice(index, 1);
Nick Janne
@njanne19
Jul 06 2017 12:26
@DanCouper what do you mean
Dan Couper
@DanCouper
Jul 06 2017 12:26
so new arr is a single value, splice will give you the thing you cut out
Nick Janne
@njanne19
Jul 06 2017 12:26
ohhhh
Dan Couper
@DanCouper
Jul 06 2017 12:26
then you are setting the state to be that single thing
Nick Janne
@njanne19
Jul 06 2017 12:26
Is it slice the one that has everything BUT the value I just cut out?
Dan Couper
@DanCouper
Jul 06 2017 12:27
no slice or splice return the thing you want sliced or spliced
Nick Janne
@njanne19
Jul 06 2017 12:27
How to I remove a specific index
on an array
Dan Couper
@DanCouper
Jul 06 2017 12:27
it you don't assign it to newArr
it will mutate state.recipes
this is really bad practice in react though
because you're modifying the state directly
Munkhmanlai
@munkhmanlai
Jul 06 2017 12:28

Finding a Remainder in JavaScript

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

// Only change code below this line
11%3=2;
var remainder;

wtf not working

Nick Janne
@njanne19
Jul 06 2017 12:29
I know I didn't wanna do it like that, I wanted to make a new arr that was a direct copy of state, then mutate it, then push it back @DanCouper
Dan Couper
@DanCouper
Jul 06 2017 12:29
JS !== maths @munkhmanlai
Munkhmanlai
@munkhmanlai
Jul 06 2017 12:29
@DanCouper so?
Dan Couper
@DanCouper
Jul 06 2017 12:29
11 % 3 = 3 is you saying assign the value three to whatever is on the left
Marianissimus
@Marianissimus
Jul 06 2017 12:29
@munkhmanlai so remainder is what you get from this 11 % 3 === x
Dan Couper
@DanCouper
Jul 06 2017 12:29
which is 11 % 3
so you get a syntax error
= does not mean equals like in maths
Stephen James
@sjames1958gm
Jul 06 2017 12:30
@munkhmanlai You never have expressions on the left of the =
You only have variables on the left of the =
Dan Couper
@DanCouper
Jul 06 2017 12:31
var myRemainderCalculation = 11 % 3;
Nick Janne
@njanne19
Jul 06 2017 12:31

@DanCouper I figured it out. Instead of having this

var newArr = this.state.recipes.splice(index, 1)

I needed to have

var newArr = this.state.recipes;
newArr.splice(index, 1);
Gus
@Guscoder
Jul 06 2017 12:32
@DanCouper @Marianissimus @wonder2991 Thanks for the advice! I
CamperBot
@camperbot
Jul 06 2017 12:32
guscoder sends brownie points to @dancouper and @marianissimus and @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 834 | @dancouper |http://www.freecodecamp.com/dancouper
:cookie: 391 | @wonder2991 |http://www.freecodecamp.com/wonder2991
:cookie: 419 | @marianissimus |http://www.freecodecamp.com/marianissimus
Munkhmanlai
@munkhmanlai
Jul 06 2017 12:32
@DanCouper okok thanks
CamperBot
@camperbot
Jul 06 2017 12:32
munkhmanlai sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 835 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
Jul 06 2017 12:35
@njanne19 Yes, but so was thinking about this, deleting stuff from a specific point in an array is a pain, but you need to do it here, and you also don't want to modify, you want to create a new array, soo:
// this will clone the current `recipes` array:
let updatedRecipes = this.state.recipes.slice();
updatedRecipes.splice(index, 1);

this.setState({ recipes: updatedRecipes });
Gus
@Guscoder
Jul 06 2017 12:35
@DanCouper I'm not clear on how I would move the splice() to the outer loop and have it still function right?
Nick Janne
@njanne19
Jul 06 2017 12:35
@DanCouper Exactly thank you
CamperBot
@camperbot
Jul 06 2017 12:35
njanne19 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 836 | @dancouper |http://www.freecodecamp.com/dancouper
Thayyeb salim
@Thayyebsalim
Jul 06 2017 12:40
Anyone on?
Stephen James
@sjames1958gm
Jul 06 2017 12:41
@njanne19 filter might be cleaner here.
deleteStatefulRecipes(food) {
    var newArr = this.state.recipes.filter((recipe) {
       return recipe.name !== food;
    });
    localStorage.recipes = JSON.stringify(newArr);
        this.setState({
           recipes: newArr
        });
  }
@Thayyebsalim yes
Thayyeb salim
@Thayyebsalim
Jul 06 2017 12:41
how does the quote generating thingy work
infinite quote fuel?
Stephen James
@sjames1958gm
Jul 06 2017 12:42
@Thayyebsalim Are you asking where you get the quotes?
Marianissimus
@Marianissimus
Jul 06 2017 12:42
@Thayyebsalim if you want that... wikipedia or something. OR you can create a file (JSON) with a finite no of quotes and use that for your app
Stephen James
@sjames1958gm
Jul 06 2017 12:43
@Thayyebsalim I created an array of quotes, but some use this API https://forismatic.com/en/api/
Paul Christian L. Catoera
@poncatoera
Jul 06 2017 12:46
any tips on this roman numeral task?
Dan Couper
@DanCouper
Jul 06 2017 12:46
ugh obviously actually using filter would be a better way of filtering the recipes :( head not working today
Marianissimus
@Marianissimus
Jul 06 2017 12:49
@poncatoera ok, ok, I'll tell you my secret:) I used 2 arrays, one for multiples of 1 and 10 [1, 10, 100] and one for multiples of 5 [5, 50, 500]. it helped me define a rule which returns the correct result no matter which base is used - 5 or 10
Dan Couper
@DanCouper
Jul 06 2017 12:50

@Guscoder something like, sorry this is a bit nasty

for (let i = 0; i < arr.length; i++) {
    var del = false;
    for (let j = 0; j < arr[i].length; j++) {
      if (arr[i][j] === elem) {
       del = true; 
      }
    }
    if (del) arr.splice(i, 1);
  }

Using indexOf (or includes) instead of the inner loop is a lot cleaner. Using filter would let you get a rid of the outer loop and the need to splice as well

Stephen James
@sjames1958gm
Jul 06 2017 12:50
@poncatoera Think about how you would do the conversion by hand. Then you can translate to code.
Paul Christian L. Catoera
@poncatoera
Jul 06 2017 12:51
hmmm okay ill try thanks guys
were u guys able to do this easily? id be down if im the only one having hard time with this lol
Gus
@Guscoder
Jul 06 2017 12:52
@DanCouper OK, thanks again!
CamperBot
@camperbot
Jul 06 2017 12:52
guscoder sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: guscoder already gave dancouper points
Marianissimus
@Marianissimus
Jul 06 2017 12:54
@poncatoera I don't know how I did it, maybe I was having a very good day, but it's probably the best code idea I ever had, using those arrays... it can convert up to 400.000 only because i can't find bigger roman symbols
Jayne
@jayne88
Jul 06 2017 12:54
What am I doing wrong here!!

```var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar = new Car(3,1,2);
```

CamperBot
@camperbot
Jul 06 2017 12:54
:bulb: to format code use backticks! ``` more info
Paul Christian L. Catoera
@poncatoera
Jul 06 2017 12:54
@Marianissimus okay thanks ill try this
CamperBot
@camperbot
Jul 06 2017 12:54
poncatoera sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 421 | @marianissimus |http://www.freecodecamp.com/marianissimus
Stephen James
@sjames1958gm
Jul 06 2017 13:01
@jayne88 You added parameters, but you didn't use them?
@poncatoera My first attempt was a lot of repetitive code.
Paul Christian L. Catoera
@poncatoera
Jul 06 2017 13:03
did u use remainder "%" operation
?
Jayne
@jayne88
Jul 06 2017 13:05
@sjames1958gm I didn't? I'm sorry that's a really silly question
Stephen James
@sjames1958gm
Jul 06 2017 13:06
@jayne88 Inside the function you aren't using wheels, seats or engines to set the values on the object (this.wheels, etc)
@poncatoera I didn't I used subtraction. As I added each roman numeral to the answer I subtracted from the value to convert
Paul Christian L. Catoera
@poncatoera
Jul 06 2017 13:07
@sjames1958gm okay
Thayyeb salim
@Thayyebsalim
Jul 06 2017 13:28
thanks @Marianissimus @sjames1958gm
CamperBot
@camperbot
Jul 06 2017 13:28
thayyebsalim sends brownie points to @marianissimus and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @marianissimus |http://www.freecodecamp.com/marianissimus
:star2: 8000 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ravi Kishore Thella
@ravikishorethella
Jul 06 2017 13:32
@sjames1958gm congrats #8k :smile:
Thomas
@sjurs1
Jul 06 2017 13:33

Hi guys, need some help with this:

$(document).ready(function() {
  let storage = "";
  let number = [];

  $("#AC").click(function() {
    storage = "";
    number = [];
    $("#output").text(0);
  })

  $(".numbers").click(function() {
    var command = $(this).data("command");
    $("#output").append(command);
    storage += command;
    console.log(storage);
    if (storage.length > 14) {
      alert("Digit limit exceeded!");
      $("#output").text("");
      storage = "";
    }
  });

  $(".operators").click(function() {
    number.push(parseFloat(storage));
    storage = "";
    console.log(number);
    if (number.length > 1) {
      var id = $(this).attr("id");
      switch (id) {
        case "x":
          $("#output").text(id);
          number[0] = number[0] * number[1];
          number.pop();
          $("#output").text(number[0]);
          break;
        case "/":
          $("#output").text(id);
          number[0] = number[0] / number[1];
          number.pop();
          $("#output").text(number[0]);
          break;
        case "+":
          $("#output").text(id);
          number[0] = number[0] + number[1];
          number.pop();
          $("#output").text(number[0]);
          break;
        case "-":
          $("#output").text(id);
          number[0] = number[0] - number[1];
          number.pop();
          $("#output").text(number[0]);
          break;
        case "=":
          $("#output").text(number[0]);
          break;
      }
    }
  });
});

I just think I need some ideas. Should I scrap the method of pushing two numbers into the array numbers and then perform the operation? The way I have it now I'm always a step behind, for example pressing 5 + 5 - outputs 0, not 10. I understand why this happens, I'm just wondering if I should just go for something else. I'm thinking of letting the user insert all numbers and operations and only calculate the answer after = is pressed instead. Also, how would I make sure that you can only press numbers after pressing an operator and not subsequent operators?

Ravi Kishore Thella
@ravikishorethella
Jul 06 2017 13:33
@sjames1958gm ty
count starts again :sweat_smile:
CamperBot
@camperbot
Jul 06 2017 13:33
ravikishorethella sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8001 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jayne
@jayne88
Jul 06 2017 13:39
@sjames1958gm Thank you again, I think I am just being a bit silly, maybe I've been sitting in front of my computer for too long!
@sjames1958gm I was being silly, I've fixed that now. Thanks again for your help!
CamperBot
@camperbot
Jul 06 2017 13:44
jayne88 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8002 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
EpicTriffid
@EpicTriffid
Jul 06 2017 13:44
Hi guys. my brain has really hit a block. Im writing my weather app and trying to say, when the icon summary says "this", display "this" background, where the icon and the background are different each time. But I'm having difficulty working out the logic, especially when moving between HTML and JS. Any ideas?
Nick Janne
@njanne19
Jul 06 2017 13:47
can you share some of your code @EpicTriffid
EpicTriffid
@EpicTriffid
Jul 06 2017 13:48
Its not responsive, just so ya know
@njanne19 you can see under the skycons section of JS where im trying to match the references in the html, and then use the url for the background
I tried just doing it in JS exclusively, but wanted to clean it up
Marianissimus
@Marianissimus
Jul 06 2017 13:50
@EpicTriffid oh, this :cry:
                  });
                });
              }); 
          });  
        }         
      });
    });
  });
EpicTriffid
@EpicTriffid
Jul 06 2017 13:51
@Marianissimus It looks awful doesnt it?! I don't know how not to do it
Nick Janne
@njanne19
Jul 06 2017 13:52
@EpicTriffid I'm confused as to exactly what your issue is? It seems like the backgrounds are working at least for me.
EpicTriffid
@EpicTriffid
Jul 06 2017 13:52
@njanne19 Hmm
Try again
Maybe the save didn't go through
Nick Janne
@njanne19
Jul 06 2017 13:53
If I change iconsum to any of the other values you have described into the if statement you have the background changes
Gus
@Guscoder
Jul 06 2017 13:53
Need some guidance here: We've defined a function, countOnline; use a for...in statement within this function to loop through the users in the users object and return the number of users whose online property is set to true.
let users = {
  Alan: {
    age: 27,
    online: false
  },
  Jeff: {
    age: 32,
    online: true
  },
  Sarah: {
    age: 48,
    online: false
  },
  Ryan: {
    age: 19,
    online: true
  }
};

function countOnline(obj) {
  // changecode below this line
  let i = 0;
  for (let user in obj) {
    if (user.online === true) {
      i += 1;
    }
    return i;
  }

  // change code above this line
}

console.log(countOnline(users));
can't get it to return the number of users that are true. keeps returning 0.
EpicTriffid
@EpicTriffid
Jul 06 2017 13:55
@njanne19 Are you seeing the urls in the html or the js?
Marianissimus
@Marianissimus
Jul 06 2017 13:56
@EpicTriffid I don't really know; some say use more callbacks
EpicTriffid
@EpicTriffid
Jul 06 2017 13:57
I guess the main question to this, is how to reference a url within a html element from js?
Marianissimus
@Marianissimus
Jul 06 2017 13:59
@EpicTriffid document.getElementByID("id").getAttribute("href") ?
@EpicTriffid and, of course, to assign it you have setAttribute
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 14:01
@Guscoder put your return i; after your loop ends
Gus
@Guscoder
Jul 06 2017 14:02
@SweetCodingInc Tried it. Did not work.
Nick Janne
@njanne19
Jul 06 2017 14:03
@Guscoder you could try making an array of Names by using Object.keys(obj) where obj is any JSON object
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 14:03
@Guscoder Your if condition is also wrong, it should be
if (obj[user].online === true) {
user will be key in your object
Nick Janne
@njanne19
Jul 06 2017 14:04
@EpicTriffid I'm seeing your JS but I don't see a problem with the way you're currently doing it
Gus
@Guscoder
Jul 06 2017 14:05
@SweetCodingInc Ah ha! I was wondering about that but didn't quite know how to fix it. Appreciate your help thanks!
CamperBot
@camperbot
Jul 06 2017 14:05
guscoder sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 83 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Jul 06 2017 14:05
@Guscoder :+1:
EpicTriffid
@EpicTriffid
Jul 06 2017 14:19
@njanne19 Thanks for looking anyway. I went back to my original method, which works at the very least. Also reduced the number of callbacks
CamperBot
@camperbot
Jul 06 2017 14:19
epictriffid sends brownie points to @njanne19 :sparkles: :thumbsup: :sparkles:
:cookie: 324 | @njanne19 |http://www.freecodecamp.com/njanne19
Nick Janne
@njanne19
Jul 06 2017 14:21
@EpicTriffid sounds good! I'm quite impressed with the weather app so don't give up! also you can make this responsive pretty easily if you want to by using media queries
ioakeimo
@ioakeimo
Jul 06 2017 14:22

Hello everyone. I have something like this:

const circle = {
        centerX: 1,
        centerY: 1,
        diameter: 20,
        radius: 20 / 2
    };

I would like to initialise radius like so radius: this.diameter / 2 but I'm getting an error. What is the right way to declare radius as a calculated result depending on diameter?

Markus Kiili
@Masd925
Jul 06 2017 14:27
@ioakeimo Inside an object literal this doesn't point to the object being created. So you need to do something else like this:
var diameter = 20;
const circle = {
        centerX: 1,
        centerY: 1,
        diameter: diameter,
        radius: diameter / 2
};
georgebatton
@georgebatton
Jul 06 2017 14:27
I'm trying to create an animation with javascript with a bouncy ball going off the walls in all directions. I have all the x and y coordinates defined but all the ball does is bounce from one corner to the other. How do I get it to bounce all over the place?
Markus Kiili
@Masd925
Jul 06 2017 14:28
@georgebatton What do you mean by all over the place?
Stephen James
@sjames1958gm
Jul 06 2017 14:28
@georgebatton Add some randomness in the bounces?
georgebatton
@georgebatton
Jul 06 2017 14:29

here's my code so far:
var x = 0;
var y = 0;
//speed of ball
var speed = 0;

draw= function() {
background(201, 201, 240);
ellipse(x,y,20,20);
//ball horizontal path
//bounces off right wall
if (x > 390) {speed = -1;}
//bounces off left wall
if (x < 10) {speed = 1;}
//ball vertical path
//bounces off ceiling
if (y < 10) {speed = 1;}
//bounces off floor
if (y > 390) { speed = -1;}
//ball touches top wall

x=x + speed;
y=y + speed;

};

I want it to bounce around like pong.
Steven Frederick
@sfrederick22
Jul 06 2017 14:30
@ioakeimo or make radius a method. getRadius = function(){ return diameter /2 };
Nick Janne
@njanne19
Jul 06 2017 14:30
@ioakeimo I don't think you can due to scope rules. Try this instead
const circle = {
        centerX: 1,
        centerY: 1,
        diameter: 20
  };
let radius = circle.diameter/2;
circle.radius = radius;

console.log(circle.radius);
ioakeimo
@ioakeimo
Jul 06 2017 14:34
@njanne19 I was trying to keep it all in one declaration. Thanks for the suggestion though :)
Btw this could also be written as cricle.radius = circle.diameter / 2; the let part is redundant ;)
CamperBot
@camperbot
Jul 06 2017 14:34
ioakeimo sends brownie points to @njanne19 :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @njanne19 |http://www.freecodecamp.com/njanne19
georgebatton
@georgebatton
Jul 06 2017 14:36
@sjames1958gm How do I add randomness to the bounce?
ioakeimo
@ioakeimo
Jul 06 2017 14:37
@sfrederick22 that could be an option too but the point is to avoid calling methods all the time. The engine might eventually optimise the output but why rely on engines for optimisation when you can do it programmatically? ;)
Stephen James
@sjames1958gm
Jul 06 2017 14:39
@georgebatton It appears you only bounce parallel to the walls. you need to have speed in the x and speed in the y direction.
To add randomness, don't just bound straight off the wall, add in some Math.random()
ioakeimo
@ioakeimo
Jul 06 2017 14:39
@Masd925 thanks for your answer, didn't saw it at first because I only had a "1" indication in my notifications saw I only saw the last one. :)
CamperBot
@camperbot
Jul 06 2017 14:39
ioakeimo sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4288 | @masd925 |http://www.freecodecamp.com/masd925
Steven Frederick
@sfrederick22
Jul 06 2017 14:39
@ioakeimo true :)
Aman Agarwal
@amanagarwal-sopho
Jul 06 2017 14:40
i want to learn mean stack can anyone recommend some good resources?
georgebatton
@georgebatton
Jul 06 2017 14:42
@sjames1958gm I have the var speed = 0. Is that where I need to add the speed for y?
Stephen James
@sjames1958gm
Jul 06 2017 14:44
@georgebatton Yes. xspeed and yspeed - you will need to use vector math or trig
I don't know the maths right off hand
georgebatton
@georgebatton
Jul 06 2017 14:44
ok
shivam gupta
@shivamg11000
Jul 06 2017 14:44
@amanagarwal-sopho start from frontend
codeolas
@codeolas
Jul 06 2017 14:48
Hey guys, this is my codepen for the wikipedia app. I'm stuck at the hover and click functions for the resulting divs. I'm targeting the "results" class for click and hover, but it doesn't work. Anybody knows why?
https://codepen.io/codeolas/pen/wepera
Stephen James
@sjames1958gm
Jul 06 2017 14:49
@amanagarwal-sopho https://www.youtube.com/playlist?list=PLillGF-RfqbZMNtaOXJQiDebNXjVapWPZ
This guy has pretty good stuff.
ioakeimo
@ioakeimo
Jul 06 2017 14:52
@codeolas Where is the results class in your html?
Stephen James
@sjames1958gm
Jul 06 2017 14:52
@codeolas Those items don't exist when you attach the handlers. You need to attach them when you create them.
georgebatton
@georgebatton
Jul 06 2017 14:53
thanks diego
Diego Mayer
@Chrono79
Jul 06 2017 14:53
:+1:
codeolas
@codeolas
Jul 06 2017 14:53

@ioakeimo

function handleApi(data){
    console.log(data);
    for (i=0; i < 10 ; i++){
  $("#target").append('<div class="results" id="' + i + '">' + '<h4>' + data[1][i] + '</h4>' + "<p>" +data[2][i] + '</p></div>');
       }
     };

it's not in the html, it's in the javascript

shivam gupta
@shivamg11000
Jul 06 2017 14:55
what is the best practise of using CSS with React
1) using CSS in js
or
2) using CSS in CSS
Stephen James
@sjames1958gm
Jul 06 2017 14:55

@codeolas

  $("#target").append('<div class="results" id="' + i + '">' + '<h4>' + data[1][i] + '</h4>' + "<p>" +data[2][i] + '</p></div>').click(clickResults);

The append returns the element where you can attach the handler ^^

codeolas
@codeolas
Jul 06 2017 14:56
@sjames1958gm Ok, let me see...
Nick Janne
@njanne19
Jul 06 2017 14:56
@shivamg11000 it might be better if your components have style variables in JS, and your components that exist always (body, background, etc) are styled in CSS
shivam gupta
@shivamg11000
Jul 06 2017 14:57
@njanne19 what about selector , pseudo-classes in css,
And use of Sass and Scss
Diego Mayer
@Chrono79
Jul 06 2017 14:57
@shivamg11000 you have a long post here: https://survivejs.com/react/advanced-techniques/styling-react/
Tiago Correia
@tiagocorreiaalmeida
Jul 06 2017 15:01
good afternoon
Stephen James
@sjames1958gm
Jul 06 2017 15:02
@tiagocorreiaalmeida :wave:
Nick Janne
@njanne19
Jul 06 2017 15:02
@shivamg11000 then there's a potential to have it in CSS instead. Remember that you wanna label elements that you render in React with className and then you should be able to edit it in CSS
Generally speaking you don't wanna have too too much style in JS
codeolas
@codeolas
Jul 06 2017 15:03
@sjames1958gm That works, but I get 10 messages - I'm guessing one for each div. I need it to work only for the div that's being clicked, not all.
Munkhmanlai
@munkhmanlai
Jul 06 2017 15:03
what if done an assignment on freecodecamp 2 times and still forgot about how to do it
Tiago Correia
@tiagocorreiaalmeida
Jul 06 2017 15:03
just need a quick helpmy brain is freezing, imagina you have a string like this "ball" and you ahve a array like this arr = [[2,"ball"],[3,"square"]]
Munkhmanlai
@munkhmanlai
Jul 06 2017 15:03
ughhh
Tiago Correia
@tiagocorreiaalmeida
Jul 06 2017 15:03
imagine you wanna find the ball in the array what's the easier way to do that?
Stephen James
@sjames1958gm
Jul 06 2017 15:03
@codeolas Interesting - I would have thought they would only happen for the clicked element.
Diego Mayer
@Chrono79
Jul 06 2017 15:04
@tiagocorreiaalmeida use indexOf and brackets to search the second element of each subarray
Stephen James
@sjames1958gm
Jul 06 2017 15:04
@tiagocorreiaalmeida You'd have to loop
Tiago Correia
@tiagocorreiaalmeida
Jul 06 2017 15:04
and then I update the array based on the return number thanks @Chrono79 and @sjames1958gm
CamperBot
@camperbot
Jul 06 2017 15:04
tiagocorreiaalmeida sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8003 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 4459 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Jul 06 2017 15:05
@tiagocorreiaalmeida There is an array find function that allows you to pass it a function to match the value
Munkhmanlai
@munkhmanlai
Jul 06 2017 15:05

Counting Cards

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.
Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'

You will write a card