These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Aug 2017
aRtoo
@artoodeeto
Aug 17 2017 00:00
@sjames1958gm aight im gonna try sir.
@sjames1958gm yo bro. its so unreal but im correct. i just added an equal sign on my first if. i passed the test. but im sketchy. can you check??

function sumFibs(num) {

  var frst = 1;
  var scnd = 1;
  var res = 0;
  var sumOdd = 0;

  for(var i=0; i<num; i++){
    res = frst + scnd;
    frst = scnd;
    scnd = res;

   if(res<=num){
      if(res % 2 === 1){
         sumOdd += res;
     }
   }
    }

  return sumOdd + 1 + 1;
}

//sumFibs(10); //correct
Stephen James
@sjames1958gm
Aug 17 2017 00:08
@artoodeeto You have extra checks you don't need.
Your loop will run long after the answer is determined.
You only need 33 loops for num = 40000000, but your code will loop 4000000 times
You get the right answer because it doesn't do anything after num > res
var sumOdd = 2;
while (res < num) {
      res = frst + scnd;
    frst = scnd;
    scnd = res;

      if(res % 2 === 1) {
         sumOdd += res;
     }
}
Bradley Sands
@sandsbe
Aug 17 2017 00:11
Any tips on this Tic Tac Toe logic?
I've got the look and feel down, time to finish the math.
Stephen James
@sjames1958gm
Aug 17 2017 00:12
@sandsbe Do you want it unbeatable? There are algorithms for that (min/max)
Bradley Sands
@sandsbe
Aug 17 2017 00:17
@sjames1958gm I think the user story is unbeatable so sure. I've been googling tic tac toe for days. All the links lead to fairly awful examples. Have a good one?
Christopher McCormack
@cmccormack
Aug 17 2017 00:27
@sandsbe Google minimax, there are plenty of examples. They might be in other languages but should be easy enough to grok
Gersho
@Gersho
Aug 17 2017 00:39
i went with random, having the game force a draw everytime gets old very fast, it's supposed to be a children game
Christopher McCormack
@cmccormack
Aug 17 2017 01:02
Random doesn't help teach a very interesting algorithm though
Stephen James
@sjames1958gm
Aug 17 2017 01:02
@sandsbe The user story mentions nothing about unbeatable.
I made my beatable, but the computer plays "smart". Rules in order (center square may be first)
  1. If the computer can win it does.
  2. If the computer can block it does
  3. Take the center square if open.
  4. random
Gersho
@Gersho
Aug 17 2017 01:06
i had a system that attribute a score to each tile based on what's on the same line/column/diag, but in the end the computer was simply blocking the game (and winning if you let him)
Christopher McCormack
@cmccormack
Aug 17 2017 01:08
@sjames1958gm I think unbeatable used to be a bonus user story
It's in the zipline video
Joseph
@revisualize
Aug 17 2017 01:10
Hey.
Christopher McCormack
@cmccormack
Aug 17 2017 01:11
@revisualize heya
Stephen James
@sjames1958gm
Aug 17 2017 01:11
@cmccormack Ah, been awhile since watched it.
Joseph
@revisualize
Aug 17 2017 01:11
@cmccormack So. My day. Hardware failure.
@cmccormack We had a piece of hardware that controls all of the wifi for the residents across our 1million sq ft campus DIE.
Gersho
@Gersho
Aug 17 2017 01:12
and the million dollar question: did @revisualize backup his data ?
oh that kind
so you only had to deal with a riot ?
Christopher McCormack
@cmccormack
Aug 17 2017 01:14
@revisualize your local controller? Do you not have active/standby?
Gersho
@Gersho
Aug 17 2017 01:14
he could mean the server hosting a captive portal
Joseph
@revisualize
Aug 17 2017 01:15
@cmccormack HA HA HA HA!
@Gersho Backups!?
@cmccormack HA HA HA HA!
We didn't have a backup of the device config.
We didn't have a standby.
We barely got the device to boot to get a backup off of it today.
Gersho
@Gersho
Aug 17 2017 01:16
of course you didn't, nobody ever does
Joseph
@revisualize
Aug 17 2017 01:16
So, we have a backup now.
But, the motherboard is shot.
Gersho
@Gersho
Aug 17 2017 01:16
you couldn't access the data w/o powering it up ?
Joseph
@revisualize
Aug 17 2017 01:16
The whole device needs to be RMA'd
@Gersho This is networking hardware not a server.
Gersho
@Gersho
Aug 17 2017 01:17

So, we have a backup now.

but next time it crash, backup will be 2years old ;p

Joseph
@revisualize
Aug 17 2017 01:17
Non-virtualized networking hardware.
Christopher McCormack
@cmccormack
Aug 17 2017 01:17
We have lots of backups :) We pull them every few min if there is a diff to a set of redundant logging servers
Joseph
@revisualize
Aug 17 2017 01:17
@Gersho We have actually set a task on the schedule to plan backups for this service.
Gersho
@Gersho
Aug 17 2017 01:17
:)
Joseph
@revisualize
Aug 17 2017 01:18
All of our other servers and networking equipment is backed up.
Christopher McCormack
@cmccormack
Aug 17 2017 01:18
@revisualize you should have your director read The Phoenix Project
Joseph
@revisualize
Aug 17 2017 01:18
Just not this one piece of equipment that crashed today.
@cmccormack I have the book. I should read it.
I bought the book months ago. Haven't read it.
Christopher McCormack
@cmccormack
Aug 17 2017 01:18
It's good - I met the author a few months ago, really interesting guy
Gersho
@Gersho
Aug 17 2017 01:18
of course, if it had been backed properly, it wouldn't have crashed anyway
it's like umbrella, you take it so it doesn't rain
Christopher McCormack
@cmccormack
Aug 17 2017 01:19
Think of all the other equipment that isn't currently down, though. Then panic!
Gersho
@Gersho
Aug 17 2017 01:19
@cmccormack well no wifi for a lot of people for more than 10mins is riot material so it's panic alright on it's own
Christopher McCormack
@cmccormack
Aug 17 2017 01:19
no wifi, I'm going home
marcus dylan johnson
@mdjohns
Aug 17 2017 01:23
Anyone want to tell me if I'm on the right track for the Palindromes algo challenge?
Joseph
@revisualize
Aug 17 2017 01:25
@djohnson501 Show your code?
@djohnson501 Or show whatever?
marcus dylan johnson
@mdjohns
Aug 17 2017 01:27
@revisualize Not finished yet. Trying to work through the pieces, but I could be way off. Seems like the first thing to do is get everything in lower case so I can iterate through it. From there, I know I should be using string.replace() to remove spaces, and special characters. Does that seem accurate?
Here's the little chunk I've got to remove spaces.

function palindrome(str) {
  var cleanStr = str.toLowerCase();
  cleanStr = cleanStr.replace(/\s\g/, "");

}
palindrome("race car");
Joseph
@revisualize
Aug 17 2017 01:29
@djohnson501 You need to remove more than just spaces. You need to remove all non-alphanumeric characters. Ergo, you need to keep all alphanumeric characters.
@djohnson501 There is a set of regex codes that you could use or you could just say not ??(^) what you want to keep.
marcus dylan johnson
@mdjohns
Aug 17 2017 01:30
So I should just specify keep a-z and 0-9?
Joseph
@revisualize
Aug 17 2017 01:31
@djohnson501 Ergo, you need to keep all alphanumeric characters.
marcus dylan johnson
@mdjohns
Aug 17 2017 01:31
Cool.
Gersho
@Gersho
Aug 17 2017 01:35
not a-Z ?
Stephen James
@sjames1958gm
Aug 17 2017 01:35
After toLowerCase no
marcus dylan johnson
@mdjohns
Aug 17 2017 01:36
cleanStr.replace(/\W+/g, "");
Gersho
@Gersho
Aug 17 2017 01:36
oh didn't see it was done before
Stephen James
@sjames1958gm
Aug 17 2017 01:36
@djohnson501 That will still leave _ behind
marcus dylan johnson
@mdjohns
Aug 17 2017 01:36
Hmmmmmm
Stephen James
@sjames1958gm
Aug 17 2017 01:37
@djohnson501 You can use either [] or | to combine regex
marcus dylan johnson
@mdjohns
Aug 17 2017 01:42
How about
cleanStr.replace(/\W+|_/g, "");
Joseph
@revisualize
Aug 17 2017 01:43
@djohnson501 Depends on where that is placd.
marcus dylan johnson
@mdjohns
Aug 17 2017 01:43
That seems to be doing the trick.
In what way?
Christopher McCormack
@cmccormack
Aug 17 2017 01:44
@djohnson501 the + isn't necessary, FYI, as you're doing a global search for individual characters
marcus dylan johnson
@mdjohns
Aug 17 2017 01:45
Gotcha :+1:
Zebralight
@zebralight
Aug 17 2017 01:51
https://gist.github.com/anonymous/422eab1c41d7ac550590c6da4750aaa8 I was expecting the last line of code to increment the value of f.value by 1, but instead I get an error message. I was wondering why that is
marcus dylan johnson
@mdjohns
Aug 17 2017 01:59
I could be wrong, but it looks like instance is a local variable. It is only called within the first Foo function, and so it is local to that function.
Christopher McCormack
@cmccormack
Aug 17 2017 02:00
@zebralight try moving instanceMethods into Foo
Zebralight
@zebralight
Aug 17 2017 02:00
so I thought that local variables were defined with the keyword (var/let/const) and not as a property as it is in the code
@cmccormack I should've added the caveat...
that I don't want to move one of those into another
which is why I'm using the defaults method
defaults function, rather
Ginger
@GingerChew
Aug 17 2017 02:09
I'm getting confused by this regex, can I get a second opinion?
var regE = /\[^aeiou]/;

// This regex should read out that it will only pick the letters that are not aeiou, right?
Christopher McCormack
@cmccormack
Aug 17 2017 02:12
@GingerChew it may only match one
Joseph
@revisualize
Aug 17 2017 02:12
@GingerChew Not a e i o u
@GingerChew but, that's the first character that is not an a, e, i o or u
Christopher McCormack
@cmccormack
Aug 17 2017 02:12
oh get rid of the backslash before the opening brace
Joseph
@revisualize
Aug 17 2017 02:14
@GingerChew I used some regex kind of like that for my Pig Latin challenge:
var search = str.search(/[aeiou]/);
Christopher McCormack
@cmccormack
Aug 17 2017 02:14
> var regE = /\[^aeiou]/
> 'this is a test'.replace(regE, '') // Replaces nothing as you are escaping your opening brace
'this is a test'
> var regE = /[^aeiou]/
> 'this is a test'.replace(regE, '') // Replaces only first character, default without global flag 'g'
'his is a test'
> var regE = /[^aeiou]/g
> 'this is a test'.replace(regE, '') // Replaces all characters that aren't vowels
'iiae'
Ginger
@GingerChew
Aug 17 2017 02:16
@cmccormack okay, that helps a bunch, so I'm deff on the right path then
Christopher McCormack
@cmccormack
Aug 17 2017 02:17
for the most part
Long Nguyen
@longnt80
Aug 17 2017 02:17
I always uses this to test my regexp http://regexr.com/
@GingerChew
Ginger
@GingerChew
Aug 17 2017 02:20
//when I run this code though, it ignores the second if statement and just returns 'californiaway'
function translatePigLatin(str) {
  var regE = /[^aeiou]/;
  if (str[0] != regE) {
    str = str.substring(0) + 'way';
  } else if (str[0] == regE) {
    for (var i = 0; str[i] != regE;i++) {
      str = str.substring(i) + str.splice(0,i+1) + 'ay';
    }
  }
  return str;
}
translatePigLatin('california');
Christopher McCormack
@cmccormack
Aug 17 2017 02:21
that's not quite how you want to use that
Ginger
@GingerChew
Aug 17 2017 02:21
okay, should I be using it in a function like .search()?
I've seen that used before
Long Nguyen
@longnt80
Aug 17 2017 02:22
@GingerChew use .match()
@GingerChew I think your logic is not quite right
Ginger
@GingerChew
Aug 17 2017 02:25
thats entirely possible @longnt80 where am I slipping?
Long Nguyen
@longnt80
Aug 17 2017 02:26
@GingerChew first, this str[0] != regE won't work
str[0] is c
regE is /[^aeiou]/
they will always be different, that's why only your first condition is met
else if (str[0] == regE) will never be true
use .match() instead
Ginger
@GingerChew
Aug 17 2017 02:30
Okayyyy, thats making more sense. I think I got into that cause I was over logic-ing
hows this look now?
function translatePigLatin(str) {
  var regE = /[aeiou]/;
  if (str[0].match(regE)) {
    str = str.substring(0) + 'way';
  } else {
    str = str.substring(1) + str[0] + 'ay';
  }
  return str;
}
it doesn't fix it for words like glove, but I wanna make sure I'm on a good path
Long Nguyen
@longnt80
Aug 17 2017 02:30
yes, it is on the right path
Ginger
@GingerChew
Aug 17 2017 02:30
sweet
@longnt80 thanks m8
CamperBot
@camperbot
Aug 17 2017 02:31
gingerchew sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 508 | @longnt80 |http://www.freecodecamp.com/longnt80
Huỳnh Trần Khanh
@khanh2003
Aug 17 2017 02:58
Why in this function, 4 isn't logged?
function* counting() {
    while (1) {
        let x = yield 0;
        console.log(x);
    }
}
const gen = counting();
gen.next(4);
gen.next(6);
gen.next(1);
I think this is the key to solving the wiki challenge
marcus dylan johnson
@mdjohns
Aug 17 2017 03:07
I'm now passing all of the tests for "true" on the palindromes challenge. Trying to figure out what I've done wrong for the false cases
function palindrome(str) {
  var cleanStr = str.toLowerCase();
  cleanStr = cleanStr.replace(/W|_|\s/g, "");
  var cleanArr = Array.from(cleanStr);
  if (cleanArr == cleanArr.reverse()){
    return true;
  } else {
    return false;
  }
}
palindrome("1 eye for of 1 eye.");
Gersho
@Gersho
Aug 17 2017 03:07
the api's doc ? well yeah of course it is
Adam Bohannon
@abohannon
Aug 17 2017 03:19
@djohnson501 which one are you coming up false for?
marcus dylan johnson
@mdjohns
Aug 17 2017 03:21
@abohannon I'm failing all of the tests that should return false (the non-palindromes).
Adam Bohannon
@abohannon
Aug 17 2017 03:23
You can't directly compare two arrays.
Try joining them into strings then comparing @djohnson501
you have to split into an array to reverse, but you can immediately .join() back into a string
marcus dylan johnson
@mdjohns
Aug 17 2017 03:32
For some reason my brain is really hanging up on this. So I split it into an array, reversed it, and now it's back into a string. Since there's no reverse method for strings, how do I compare them? Is it still possible to use an if/else?
function palindrome(str) {
  var lowerCaseStr = str.toLowerCase();
  lowerCaseStr = lowerCaseStr.replace(/W|_|\s/g, "");
  var myArr = Array.from(lowerCaseStr).reverse().join();

}
palindrome("1 eye for of 1 eye.");
Adam Bohannon
@abohannon
Aug 17 2017 03:33
No worries, lemme take a look
marcus dylan johnson
@mdjohns
Aug 17 2017 03:34
OH wait. I think I'm feeling stupid
Gersho
@Gersho
Aug 17 2017 03:34
reread your last comment
according to what you said you already have a normal string and a reversed string
Adam Bohannon
@abohannon
Aug 17 2017 03:36
@djohnson501 remember to pass the join() method a separator so you're joining the array at the correct place.
Claudio Restifo
@Marmiz
Aug 17 2017 03:37

@khanh2003 it's kinda complex, but with a generator the function "stop" (not really but make it simple) at the first yield and wait for a done. So the first argument (if passed with next) won't show up.

Or to quote the MDN:

Calling a generator function does not execute its body immediately; an iterator object for the function is returned instead. When the iterator's next() method is called, the generator function's body is executed until the first yield expression, which specifies the value to be returned from the iterator [...] Calling the next() method with an argument will resume the generator function execution, replacing the yield statement where execution was paused with the argument from next().

So in your example if you want 4 to be logged you should:

function* counting() {
    while (1) {
        let x = yield 0;
        console.log(x);
    }
}
const gen = counting();
gen.next();
gen.next(4);
gen.next(6);
gen.next(1);
Adam Bohannon
@abohannon
Aug 17 2017 03:37
*joining the array into a string at the correct place
@djohnson501 so your myArr is now the reversed string (though there's a tiny problem with how it's being joined together). Once that's fixed, then you can compare this variable with your var lowerCaseStr.
Using the same sort of if/else statement you used originally.
marcus dylan johnson
@mdjohns
Aug 17 2017 03:39
.join("") ?
Adam Bohannon
@abohannon
Aug 17 2017 03:39
@djohnson501 :thumbsup:
marcus dylan johnson
@mdjohns
Aug 17 2017 03:42
Strange. Looks like I'm passing all but three of the tests. All three pass fine in the Chrome javascript console, but don't seem to be cooperating in the FCC console.
This is an example. Passes in Chrome JS console, fails on the FCC site.

function palindrome(str) {
  var lowerCaseStr = str.toLowerCase();
  lowerCaseStr = lowerCaseStr.replace(/W|_|\s/g, "");
  var revStr = Array.from(lowerCaseStr).reverse().join("");
    if(revStr === lowerCaseStr){
      return true;
    } else {
      return false;
    }
}
palindrome("0_0 (: /-\ :) 0-0");
Adam Bohannon
@abohannon
Aug 17 2017 03:44
im returning false for that one. lemme debug real quick.
marcus dylan johnson
@mdjohns
Aug 17 2017 03:45
Gotta be something wrong with my regex
Adam Bohannon
@abohannon
Aug 17 2017 03:45
insert a couple console.logs in there to see what's going on. Console.log both of your variables.
Yea, looks like it.
looks like you're still including non-alphanumeric characters
Gersho
@Gersho
Aug 17 2017 03:46
rather than trying to get rid of unwanted character in your regex, why not aim for the ones you want to keep ? (should be easier since you know what you want to keep)
arr = str.match(/[a-z0-9]/g)
Adam Bohannon
@abohannon
Aug 17 2017 03:47
http://regexr.com/ is pretty helpful for figuring out different regex combos
@Gersho makes a good point. That's very similar to what I used for my solution.
marcus dylan johnson
@mdjohns
Aug 17 2017 03:48
@abohannon That's what I'm on right now haha. And @Gersho I just had that realization on the website. Much cleaner.
Gersho
@Gersho
Aug 17 2017 03:48
i went to check mine because i couldn't understand /W|_|\s/g
Huỳnh Trần Khanh
@khanh2003
Aug 17 2017 03:50
@Marmiz ok, davidwalsh.name explains it better than you but i am giving you brownie points anyway.
TRIGGER_BROWNIE: thanks.
CamperBot
@camperbot
Aug 17 2017 03:50
khanh2003 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1024 | @marmiz |http://www.freecodecamp.com/marmiz
Joseph
@revisualize
Aug 17 2017 03:51

@djohnson501 This:

    if(revStr === lowerCaseStr){
      return true;
    } else {
      return false;
    }

could just be
return revStr === lowerCaseStr;

John
@AnonymousLords
Aug 17 2017 03:52
the new freeCodeCamp/guides looks cool :D
Joseph
@revisualize
Aug 17 2017 03:53
@AnonymousLords Where?
Adam Bohannon
@abohannon
Aug 17 2017 03:54
The React test modules are pretty awesome: http://hysterical-amusement.surge.sh/
John
@AnonymousLords
Aug 17 2017 03:54
Adam Bohannon
@abohannon
Aug 17 2017 03:55
they've all been QA'd too, so they're just waiting to be shipped to FCC's production site I think.
John
@AnonymousLords
Aug 17 2017 03:55
Guys whats wrong with this code

function repeatStringNumTimes(str, num) {

  while (str.length > str.length * num){
    str = str + (str);
 }
 return str;
}

repeatStringNumTimes("abc", 2);
Joseph
@revisualize
Aug 17 2017 03:56
@AnonymousLords That's not part of freeCodeCamp.
John
@AnonymousLords
Aug 17 2017 03:56
It was in teh contributers
They said it was the new guides
Why wont my code work?
Claudio Restifo
@Marmiz
Aug 17 2017 03:58
@abohannon they are already in the beta website
Joseph
@revisualize
Aug 17 2017 03:58
@AnonymousLords str.length > str.length * num you have the length of str constantly growing.
John
@AnonymousLords
Aug 17 2017 03:59
Im adding to str's length every time i add itself.
Joseph
@revisualize
Aug 17 2017 03:59
@AnonymousLords each iteration the condition str.length > str.length * num is evaluated.
Adam Bohannon
@abohannon
Aug 17 2017 03:59
@Marmiz hmm i didn't see them
John
@AnonymousLords
Aug 17 2017 03:59
Im trying to add itself until the length is equal to it nutipled by teh number
By if i need to fit 3 abc, then i need 3x the length
Joseph
@revisualize
Aug 17 2017 04:00
@AnonymousLords Your condition will never be false.
John
@AnonymousLords
Aug 17 2017 04:00
Create a new varaible with str.length x number?
Claudio Restifo
@Marmiz
Aug 17 2017 04:00
@abohannon my bad, they are still in alpha
Joseph
@revisualize
Aug 17 2017 04:00
@AnonymousLords Maybe.
John
@AnonymousLords
Aug 17 2017 04:01
Okay new code

function repeatStringNumTimes(str, num) {

  var strNum = str.length * num;

  while (str.length < strNum) {
    str = str + (str);
 }
 return str;
}

repeatStringNumTimes("abc", 2);
Gulsvi
@gulsvi
Aug 17 2017 04:03
@AnonymousLords :wave:
John
@AnonymousLords
Aug 17 2017 04:03
It kinda works, but why does repeatStringNumTimes("abc", 3); out put abcabcabcabc
@SkyC0der :D
marcus dylan johnson
@mdjohns
Aug 17 2017 04:04
@revisualize @abohannon @Gersho Thanks for your help on that palindrome challenge. Finally got it working after a couple hours today. Feeling good!
CamperBot
@camperbot
Aug 17 2017 04:04
djohnson501 sends brownie points to @revisualize and @abohannon and @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 335 | @gersho |http://www.freecodecamp.com/gersho
:cookie: 304 | @abohannon |http://www.freecodecamp.com/abohannon
:star2: 4438 | @revisualize |http://www.freecodecamp.com/revisualize
Adam Bohannon
@abohannon
Aug 17 2017 04:05
@djohnson501 hell yea, np. Onward!
John
@AnonymousLords
Aug 17 2017 04:05
:point_up: August 17, 2017 12:01 AM Okay added
if (0 >= num) {
    return str;
  }
Gulsvi
@gulsvi
Aug 17 2017 04:05
str = str + str
abc = abc + abc
abcabc = abcabc + abcabc = ababcabcabc
Joseph
@revisualize
Aug 17 2017 04:05
@AnonymousLords <= ?
John
@AnonymousLords
Aug 17 2017 04:05
To account for negitive numbers
Gersho
@Gersho
Aug 17 2017 04:05
@djohnson501 :thumbsup:
Joseph
@revisualize
Aug 17 2017 04:05
OH! I just one linered that challenge.
WOOT!
John
@AnonymousLords
Aug 17 2017 04:06
@SkyC0der Do i need to save str's string at start
Joseph
@revisualize
Aug 17 2017 04:06
@AnonymousLords just create a result variable.
Gulsvi
@gulsvi
Aug 17 2017 04:06
Yeah, because you have to have a reference for repeating
John
@AnonymousLords
Aug 17 2017 04:07
@revisualize Okay new code
Gulsvi
@gulsvi
Aug 17 2017 04:07
result variable will help - then you just "copy" it to that variable in your loop
John
@AnonymousLords
Aug 17 2017 04:07
works, but i need to make a way so cancels negitive numbers

function repeatStringNumTimes(str, num) {

  if (0 >= num) {
    return "";
  }

  var strString = str;

  var strNum = str.length * num;

  while (str.length < strNum) {
    str = str + (strString);
 }
 return str;
}

repeatStringNumTimes("abc", 3);
I got it
(i edited my code) :point_up: August 17, 2017 12:07 AM
I added return ""; if the number is less or 0 itself;
Joseph
@revisualize
Aug 17 2017 04:09
@AnonymousLords I just wrote this code:
function repeatStringNumTimes(str, num) {
  // repeat after me
  return (num >= 1) ? new Array(num).fill(str).join('') : "";
}
John
@AnonymousLords
Aug 17 2017 04:09
.fill?
Gulsvi
@gulsvi
Aug 17 2017 04:10
@AnonymousLords Are you going to hate us if we tell you there is a .repeat() method?
John
@AnonymousLords
Aug 17 2017 04:10
:L
Gulsvi
@gulsvi
Aug 17 2017 04:10
:)
John
@AnonymousLords
Aug 17 2017 04:10
:P
Joseph
@revisualize
Aug 17 2017 04:10
Yeah, there is a .repeat() method.
John
@AnonymousLords
Aug 17 2017 04:10
At mylevel would i know .repeat?
Gulsvi
@gulsvi
Aug 17 2017 04:10
I think it's against the "spirit" of the exercise to use .repeat()
Joseph
@revisualize
Aug 17 2017 04:10
@AnonymousLords Do you want to see all of my solutions for that challenge?
John
@AnonymousLords
Aug 17 2017 04:10
Lol okay
I solved that challange in 10 - 20minutes
Gulsvi
@gulsvi
Aug 17 2017 04:11
(but I used repeat() lol)
Joseph
@revisualize
Aug 17 2017 04:11
@AnonymousLords https://github.com/revisualize/FreeCodeCamp_Lessons/blob/master/Repeat_a_string_repeat_a_string.js
Bottom up. My oldest code is at the bottom then my newest code is at the top.
John
@AnonymousLords
Aug 17 2017 04:11
Thats the quickest i have ever done a challange lol.
Is mine to not simplified enough?
Its only 1 - 2 lines bigger
I like to space out my code
Joseph
@revisualize
Aug 17 2017 04:14
@AnonymousLords The simplest solution?
John
@AnonymousLords
Aug 17 2017 04:14
I mean for my level its pretty simple
Joseph
@revisualize
Aug 17 2017 04:14
function repeatStringNumTimes(str, num) {
     if (num <= 0) return "";
     return str.repeat(num);
}
John
@AnonymousLords
Aug 17 2017 04:15
:P
Joseph
@revisualize
Aug 17 2017 04:15
But, that's using .repeat()
John
@AnonymousLords
Aug 17 2017 04:15
Yeah, i started off using a for loop, but then changed to a while loop cause i need to check every iteration.
Joseph
@revisualize
Aug 17 2017 04:16
@AnonymousLords Look when I solved that the first time:
function repeatStringNumTimes(str, num) {
  var result = "";
  while (num > 0) {
      result += str;
      num -= 1;
    }
  return result;
}
John
@AnonymousLords
Aug 17 2017 04:16
Guys i gtg thanks @revisualize @SkyC0der
CamperBot
@camperbot
Aug 17 2017 04:16
anonymouslords sends brownie points to @revisualize and @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2421 | @skyc0der |http://www.freecodecamp.com/skyc0der
:star2: 4439 | @revisualize |http://www.freecodecamp.com/revisualize
Gulsvi
@gulsvi
Aug 17 2017 04:17
@AnonymousLords See ya
John
@AnonymousLords
Aug 17 2017 04:17
@revisualize what does += do again?
Joseph
@revisualize
Aug 17 2017 04:17
@AnonymousLords it's the same as result = result + str;
John
@AnonymousLords
Aug 17 2017 04:17
Oh okay :D
is str = str + (strString) different from str = str + strString
Before i leave
Does () matter?
I thought since it was a string it would.
Anyways @ me with the answer, i gtg, thanks for the help.
Markus Kiili
@Masd925
Aug 17 2017 04:57
Those parens don't do anything.
@AnonymousLords
madankumar sm
@madanamigo
Aug 17 2017 05:01
It's possible to concat the 2D and 3D array????
Markus Kiili
@Masd925
Aug 17 2017 05:03
@madanamigo You can concat any arrays, but the result might not be what you wan't. Multidimensional arrays are just arrays with arrays as elements.
Gersho
@Gersho
Aug 17 2017 05:03
steamroller detected D:
madankumar sm
@madanamigo
Aug 17 2017 05:04
Tq @Masd925
Joseph
@revisualize
Aug 17 2017 05:10
@Masd925 Thank you.
CamperBot
@camperbot
Aug 17 2017 05:10
revisualize sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4420 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 17 2017 05:10
@revisualize Morning. How is the :hand:
Joseph
@revisualize
Aug 17 2017 05:11
@Masd925 Broken.
LOL!
@Masd925 Seriously though. It's still broken. I'm slowly healing. I can't bend my wrist forward more than a few degrees
Markus Kiili
@Masd925
Aug 17 2017 05:13
@revisualize Hope it heals well.
Joseph
@revisualize
Aug 17 2017 05:14
@Masd925 I have at least 4 months of physical therapy.
Markus Kiili
@Masd925
Aug 17 2017 05:15
@revisualize One of the most influential lotteries of life whether you get a granny or a hot nurse for that.
Joseph
@revisualize
Aug 17 2017 05:16
@Masd925 well, I'm still in the running for the big money lottery jackpot then.
Gersho
@Gersho
Aug 17 2017 05:16
@Masd925 he'll also discover if he codes better or worse when on drugs
or maybe he already knows, i'm not a cop ^^
Joseph
@revisualize
Aug 17 2017 05:17
@Masd925 The US Powerball is at $510 Million
@Gersho I'm not on drugs any more.
@Gersho I don't like taking drugs of any kind. So, I try to get off of them as quick as possible.
Gersho
@Gersho
Aug 17 2017 05:17
:thumbsup:
Joseph
@revisualize
Aug 17 2017 05:18
@Gersho And yes, I still have the Rx bottles for all of the drugs I took. And my name is on the bottles.
Gersho
@Gersho
Aug 17 2017 05:18
didn't even knew they let you have it
Joseph
@revisualize
Aug 17 2017 05:19
@Gersho They day I broke it they shot me up with morphine and gave me 20 Vicodin.
Gersho
@Gersho
Aug 17 2017 05:19
in france the big stuff stays in the hand of the profesionals (as far as i know)
Joseph
@revisualize
Aug 17 2017 05:19
@Gersho My doctor gave me 40 oxycodone.
@Gersho My first week after I broke my wrist and had surgery was interesting. My arm hand a nerve block in it from the shoulder down.
My arm was a bag that I was carrying around.
Gersho
@Gersho
Aug 17 2017 05:28
fun
Joseph
@revisualize
Aug 17 2017 05:30
@Gersho You say fun. I say something VERY different.
Gersho
@Gersho
Aug 17 2017 05:30
oh i meant
"fun"
/sarcasm
if a kid asks you what happened tell him "cigarettes"
i'm off cya
Muhammad Hasham
@MohammadHasham
Aug 17 2017 07:15
can anyone help me with game of life?
Afiur Rahman Fahim
@faahim
Aug 17 2017 07:24

Hi everyone!

I'm building local weather app.

I'm using html geolocation to identify users location. But I also want to locate them using ipapi if the user doesn't allow the html location request in their browser. For that, i've written this function. It's working fine for the geolocation. But it doesn't work when I block geolocation request. Here is my code:

$(document).ready(function() {

    function locateYou() {

        var lat;
        var lon;

        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function (position) {
                lat = position.coords.latitude;
                lon = position.coords.longitude;
                $(".locName").html(lat+','+lon+"navigator");
            });
        } else {
            var ipApiCall = "https://ipapi.co/json";
            $.getJSON(ipApiCall, function(ipData){
                lat = ipData.latitude;
                lon = ipData.longitude;
                $(".locName").html(lat+','+lon+"ipApi");
            });
        }

    }

    locateYou();

});

Any help?

Markus Kiili
@Masd925
Aug 17 2017 07:28
@faahim Any errors on browser developer tools console?
Afiur Rahman Fahim
@faahim
Aug 17 2017 07:29
No error, I've checked every part of the code individually. They works fine standalone.

Oh! Figured it out!

Just changed the logic a little bit. I am not passing the ipApi as a else request now. I am running fetching the data from ipapi by default, then updating the data only if the user allow the geolocation request.

This works. :)
But I'd still love to know why the former doesn't work.

by the way, thanks @Masd925 :)
CamperBot
@camperbot
Aug 17 2017 07:32
faahim sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4422 | @masd925 |http://www.freecodecamp.com/masd925
Afiur Rahman Fahim
@faahim
Aug 17 2017 07:33
This is the code now:
$(document).ready(function() {

    function locateYou() {

        var lat;
        var lon;

        var ipApiCall = "https://ipapi.co/json";
        $.getJSON(ipApiCall, function(ipData){
            lat = ipData.latitude;
            lon = ipData.longitude;
            $(".locName").html(lat+','+lon+"ipApi");
        });

        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function (position) {
                lat = position.coords.latitude;
                lon = position.coords.longitude;
                $(".locName").html(lat+','+lon+"navigator");
            });
        }

    }

    locateYou();

});
Markus Kiili
@Masd925
Aug 17 2017 07:36
@faahim Not sure why the first doesn't work. It is more logical to use if/else.
Afiur Rahman Fahim
@faahim
Aug 17 2017 07:39
yes, that's why I attempted that way
Umm.. Facing a different issue now.
Markus Kiili
@Masd925
Aug 17 2017 07:40
@faahim You could try some console.log's to see what is happening there.
Afiur Rahman Fahim
@faahim
Aug 17 2017 07:41

do you have time @Masd925

I'd love to discuss.

Mind if I PM you?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 07:41
good morning everyone
can someone look into my pen? https://codepen.io/tiagocorreia/pen/brYpog after getting the first color right it will rush fast and get into a loop, in case of doubth of the color for now I have a console log that tells the enxt color
Markus Kiili
@Masd925
Aug 17 2017 07:43
@faahim Just leaving for lunch.
Afiur Rahman Fahim
@faahim
Aug 17 2017 07:43
Oh! Enjoy your lunch! :)
@Masd925
Muhammad Hasham
@MohammadHasham
Aug 17 2017 08:19
i have made the board for the game of life can someone help me with initiating the process now
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 09:01
@Masd925 you around?
shaistha
@shaistha24
Aug 17 2017 09:40

truncate a string

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(str.length>num){
    var str2 =str.slice(0,num-3)+"...";
    return str2;
  }else{

  return str;
  }
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

this code gives the desired return value that is
A-tisket...

then where is this wrong??

Johnny
@JohnnyBizzel
Aug 17 2017 09:44
@shaistha24 Run the tests - which does it fail on?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 09:45
gm @JohnnyBizzel can you give me a little help?im stuck on same point for the last 2 hours :D
Jim Tryon
@jimtryon
Aug 17 2017 09:45
I’m trying to match the test result of "Promise { 'FULFILLED' }" != "FULFILLED!"
shaistha
@shaistha24
Aug 17 2017 09:45
@JohnnyBizzel
truncateString("A-", 1) should return "A...".
truncateString("Absolutely Longer", 2) should return "Ab...".
these are the conditions -it failed on
Jim Tryon
@jimtryon
Aug 17 2017 09:45
'use strict';

require('es6-promise');

var promise = new Promise((fulfill, reject) => {
    setTimeout(function() {
        fulfill('FULFILLED');
    }, 300);
});

promise.then((success) => {
    console.log(promise);
});
Johnny
@JohnnyBizzel
Aug 17 2017 09:46
@shaistha24 In these cases you are probably just returning str which is wrong
@tiagocorreiaalmeida Ok, looking now. The code seems very complicated.
kumquatfelafel
@kumquatfelafel
Aug 17 2017 09:47
@shaistha24 when num is less than or equal to 3
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 09:48
problem is after the first color it will just loop and I have no idea why hum
Jim Tryon
@jimtryon
Aug 17 2017 09:48
I need to have the promise fulfilled with a value of 'FULFILLED' in executor after 300ms, using setTimeout
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 09:48
and thanks for looking into it
kumquatfelafel
@kumquatfelafel
Aug 17 2017 09:48
... I swear, they made that number 3 on purpose :laughing:
shaistha
@shaistha24
Aug 17 2017 09:51
@kumquatfelafel why are v taking it wrt 3
num<=3??
kumquatfelafel
@kumquatfelafel
Aug 17 2017 09:51
However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.
shaistha
@shaistha24
Aug 17 2017 09:51
@JohnnyBizzel
kumquatfelafel
@kumquatfelafel
Aug 17 2017 09:52
Basically, what they are saying is, if there's less than three characters, don't replace them all with ...
Johnny
@JohnnyBizzel
Aug 17 2017 09:52
@tiagocorreiaalmeida Should the userInput array be cleared after a wrong guess?
shaistha
@shaistha24
Aug 17 2017 09:52
its bcoz it given there thats it??or is there a reason for it to be given like that??
kumquatfelafel
@kumquatfelafel
Aug 17 2017 09:52
Just take the number of characters specified by num, then add ... after
Johnny
@JohnnyBizzel
Aug 17 2017 09:52
@shaistha24 Yes?
shaistha
@shaistha24
Aug 17 2017 09:52
@kumquatfelafel
kumquatfelafel
@kumquatfelafel
Aug 17 2017 09:53
@shaistha24 You can think of it as a sort of "we don't want to ever truncate a string by just having ..." check
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 09:53
@JohnnyBizzel no I haven't made that part that part has 2 options if strict mode is on it restart with only 1 color on the sequence with restrict mode off it will call back the last sequence and start from there, my problem is with the animation atually hum
shaistha
@shaistha24
Aug 17 2017 09:55
ok.. @kumquatfelafel thank u
CamperBot
@camperbot
Aug 17 2017 09:55
shaistha24 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 614 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Jim Tryon
@jimtryon
Aug 17 2017 09:56
Is anyone able to help with promises?
kumquatfelafel
@kumquatfelafel
Aug 17 2017 10:25
@jimtryon you're trying to run the code in the javascript version as opposed to the es6 version of repl.it
You need to specify es6 when you first start.
(the result is it doesn't recognize arrow function)
prakash chandra yadav
@prakashyadav008
Aug 17 2017 10:26
hey can anyone help me out
kumquatfelafel
@kumquatfelafel
Aug 17 2017 10:26
Jim Tryon
@jimtryon
Aug 17 2017 10:26
@kumquatfelafel where do I specify that?
prakash chandra yadav
@prakashyadav008
Aug 17 2017 10:26
i am having this tag on top of my weather app
Jim Tryon
@jimtryon
Aug 17 2017 10:27
@kumquatfelafel https://repl.it/KNcw/0
prakash chandra yadav
@prakashyadav008
Aug 17 2017 10:27
"> this tag is unnecessary there.i cross checked it and all tags are properly closed
kumquatfelafel
@kumquatfelafel
Aug 17 2017 10:28
@jimtryon can either click that link i provided, or go to repl.it then type in es6 (and click it)
Jim Tryon
@jimtryon
Aug 17 2017 10:31
@kumquatfelafel I clicked on the link and sent it to you
kumquatfelafel
@kumquatfelafel
Aug 17 2017 10:43
@jimtryon console.log(success)?
@jimtryon not sure what you want
Jim Tryon
@jimtryon
Aug 17 2017 10:43
I wasn’t sure on that part if I pass any var
oh, I’m console.log the wrong var
kumquatfelafel
@kumquatfelafel
Aug 17 2017 10:44
yeah
Jim Tryon
@jimtryon
Aug 17 2017 10:45
that was it, thanks @kumquatfelafel
CamperBot
@camperbot
Aug 17 2017 10:45
jimtryon sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 615 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Jim Tryon
@jimtryon
Aug 17 2017 10:45
I can’t believe I didn’t see that
was staring at it for awhile
Owais Ahmed
@owaisehmed
Aug 17 2017 11:16
my JS section not working
do we need to change the settings for that
?
kumquatfelafel
@kumquatfelafel
Aug 17 2017 11:17
In codepen??
Owais Ahmed
@owaisehmed
Aug 17 2017 11:19
Yes
kumquatfelafel
@kumquatfelafel
Aug 17 2017 11:21
There are a number of different reasons your JS might not be working. I have to go for now, but I'd recommend just posting the pen, and someone can probably walk you through it.
Stephen James
@sjames1958gm
Aug 17 2017 12:00
@owaisehmed post a link to your pen
Abhinav Mishra
@abhinav-m
Aug 17 2017 12:03
what is webpack
when would i need to use it
Thomas
@sjurs1
Aug 17 2017 12:16
Hi guys. I have a csv file that I want to style and publish to a server via meteor using atom. anyone have any videos or articles for something like that?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 12:37
hello
@sjames1958gm do you have a fewm inutes?
Stephen James
@sjames1958gm
Aug 17 2017 12:40
sure
@abhinav-thinktank Webpack is mechanism for compiling and bundling your app.
Abhinav Mishra
@abhinav-m
Aug 17 2017 12:41
@sjames1958gm aah yes, going through a tutorial for creating react apps without using create-react-app
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 12:43
aaaaa great, https://codepen.io/tiagocorreia/pen/brYpog if you can look into my pen if you play start you will get th animation and sound of the first color if you get them right after that the animation will be so fast and get into a loop and I have no idea why since I clear tghe interval every time I call it @sjames1958gm
Stephen James
@sjames1958gm
Aug 17 2017 12:47
@abhinav-thinktank It can compile using babel, and bundle css, html and js into one file
Abhinav Mishra
@abhinav-m
Aug 17 2017 12:47
yes!
Stephen James
@sjames1958gm
Aug 17 2017 12:47
@tiagocorreiaalmeida Looks like it happens on the second round
Abhinav Mishra
@abhinav-m
Aug 17 2017 12:47
im trying to get that setup without create-react-app
so i can understand whats happening in the background.
and to learn a bit more about webpack.
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 12:48
yeah after taht it just keeps going on and on
if it has more than 1 call to the function that happens
Stephen James
@sjames1958gm
Aug 17 2017 12:50
@tiagocorreiaalmeida Your soundTime variable as a global will get overwritten when you call sound more than once.
So the earlier timers never get cleared.
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 12:51
so it should be local?
inside the function?
Stephen James
@sjames1958gm
Aug 17 2017 12:52
@tiagocorreiaalmeida At least. but why do you have an array of arrays?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 12:53
the way was store all the moves 1 by 1 but that's dumb cause I can use a normal array and push every tiem a new color to it and I just tought about ti nwo xd
Stephen James
@sjames1958gm
Aug 17 2017 12:54
yeah
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 12:54
let me fix some of those things and see if I can solve my all the problems, thanks @sjames1958gm
CamperBot
@camperbot
Aug 17 2017 12:54
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8331 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 17 2017 12:55
@tiagocorreiaalmeida :+1:
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:00
@sjames1958gm do you remember my sequence function ? :D ```
function sequence () {
   entrys.push(colors[(Math.floor(Math.random()*4))]);
  if(entrys.length === 0){
    sound(entrys);
  }else{  
    for(var i = 0; i < entrys.length; i++){
     sound(entrys[i])
    }
    }
    console.log(entrys);
  }
look the difference jesus dotn knwop how I could be so dumb
anyway I still face the same problem of the animation / sound hum
https://codepen.io/tiagocorreia/full/brYpog/ if you dont mind giving it a new look
Petru Conduraru
@bluecondor
Aug 17 2017 13:07
Hi guys and gals! Can someone give me some tips about why this code is not working?
This is my code:
function isUniform(arr){
    for(i = 1; i < arr.length; i++){
    return arr[i-1] === arr[i];
    }
}
I am trying to compare each element in an array, and if there is at least a different one, to return false, and if they are all the same to return false
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:10
hey @bluecondor can you tell me just the name of the exercise?
I think Iu sed .filter on that and I may help you
Petru Conduraru
@bluecondor
Aug 17 2017 13:10
it is not from here
function isUniform(arr){
  for(i = 1; i < arr.length; i++){
    return arr[i-1] === arr[i];
  } 
}

isUniform([1,1,1,1]);
isUniform([2,1,1,1]);
isUniform(["a", "b", "p"]);
isUniform(["b", "b", "b"]);
It's not from FCC
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:11
its ok
Petru Conduraru
@bluecondor
Aug 17 2017 13:11
It's just a challenge
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:11
you can still use .filter
do you knwo the method»?
Petru Conduraru
@bluecondor
Aug 17 2017 13:11
no
method for arrays?
Petru Conduraru
@bluecondor
Aug 17 2017 13:11
I can check on mdn
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:11
look into it, that's atually all that you need
Petru Conduraru
@bluecondor
Aug 17 2017 13:11
thank you
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:11
it does the job for you .D
Petru Conduraru
@bluecondor
Aug 17 2017 13:12
I guess mine should also work
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:12
@sjames1958gm still thereee?:D
Petru Conduraru
@bluecondor
Aug 17 2017 13:12
I would like to debug this as well
Stephen James
@sjames1958gm
Aug 17 2017 13:12
@tiagocorreiaalmeida Yeah, you have to inject delay between sounds or they will overlap
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:12
@bluecondor what you are checking it's
if the previous is equal to the next?
that doesnt make sense based in what you want I think or I got it wrong
Petru Conduraru
@bluecondor
Aug 17 2017 13:13
yes
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:13
do run the same value trtough all the array it would be better a loop inside another loop
other way of doing it would be using .every
you only need to check if 1 is different
if it is return something
Petru Conduraru
@bluecondor
Aug 17 2017 13:13
so it is ok to use a while loop inside for?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:14
if not outside the loop return the other condition
you could just use 2 nested for
Petru Conduraru
@bluecondor
Aug 17 2017 13:14
I see
I will try this aproach before I will look into .every or filter
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:14
@sjames1958gm you mean inside the function itselft?
Petru Conduraru
@bluecondor
Aug 17 2017 13:14
@tiagocorreiaalmeida thank you very much for your suggestion!
CamperBot
@camperbot
Aug 17 2017 13:14
bluecondor sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:15
tyou welcome @bluecondor hope I didnt tell you something wrong
@sjames1958gm makign the settimeoutfunction bigger or ?
im confused and stuck on this part since yesterday tbh xd
Stephen James
@sjames1958gm
Aug 17 2017 13:16
@tiagocorreiaalmeida This is the hard part about this challenge.
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:16
yeah I know aaa,if I delay the settimeout wouldnt it be enough to delay the tiem between the sounds?
Stephen James
@sjames1958gm
Aug 17 2017 13:17
You could base your settimeout based on the index into entrys.
You would need a delay before calling sequence() after the user input to play the user input sounds
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:19
@sjames1958gm you mean by the ammount of times I have to call the function?im so confused right now, sorry to bother
a new settimeout?
after the click?
George Kech.
@georgemitnick
Aug 17 2017 13:20
Anyone alive?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:20
everyone :D
Stephen James
@sjames1958gm
Aug 17 2017 13:22
Why are you using setInterval anyway, you only want to play the sound once per call to sound?
You can pass a delay to sound increasing that for each entry in entrys.
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:22
I used only settimeout on the start to play it but I eneded up with a loop aswell
then tried to use both of them
and I got it another parameter
Stephen James
@sjames1958gm
Aug 17 2017 13:28
Here sound will delay by 1 sec * index value (use index into entrys)
sound(color, index) {
   setTimeout(function() {      
      $(".row-button div."+color+"").css("opacity", "1");
      $(".row-button div."+color+" audio").trigger('play');
      setTimeout(function() {
         $(".row-button div").css("opacity", "0.80");
      }, 500);
   }, 1000*index);
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:29
thanks @sjames1958gm will try and sorry sometimes I feel confused with those things I started js 2/3 months ago doing my best
CamperBot
@camperbot
Aug 17 2017 13:29
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: tiagocorreiaalmeida already gave sjames1958gm points
Stephen James
@sjames1958gm
Aug 17 2017 13:30
@tiagocorreiaalmeida This is the harder stuff to get ones mind around.
TBH, I would use a callback function from sound rather than a delay, the callback could be called after
the sound has played.
This forces a explicit sequence where one sound starts the next (where i is passed back to index the next entry)
function sound(color, i, cb){
  $(".row-button div."+color+"").css("opacity", "1");
  $(".row-button div."+color+" audio").trigger('play');
  setTimeout(function(){
    $(".row-button div").css("opacity", "0.80");
    if (cb) cb(i);
  },500)
}

function sequence () {console.log(entrys);
  entrys.push(colors[(Math.floor(Math.random()*4))]);
  let f = (i) => {
    i++;
    if (i < entrys.length) {
     sound(entrys[i], i, f)
    }
  }
  sound(entrys[0], 0, f)
}
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:33
that's a bit of es6 right?have no idea how to read some of those things :D
i mean the =>
cause I dont wanna copy paste this I wanna understand it like others stuffs so next time im able to do it on my own
Stephen James
@sjames1958gm
Aug 17 2017 13:40
That is a good attitude - the (i) => is the same as function(i)
@tiagocorreiaalmeida I'll be around - but at work now, so not so responsive. good luck
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 13:41
the code doesnt work and im confused with the if(cb) cb(i); :D
yeah np and thanks for your time tought me that still there's alot to learn
Stephen James
@sjames1958gm
Aug 17 2017 13:54
@tiagocorreiaalmeida if (cb) cb(i) is only making sure callback is not undefined then calling it with the index value
Blauelf
@Blauelf
Aug 17 2017 14:45
codeschool free weekend again, starting 2017-08-18 10:00:00 EST (whatever EST is, GMT-4?).
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 15:29
@sjames1958gm that's so confusing to me and I tried the code but seems is not working for some reason And I think this is the point I have to stop go back and learn more about setInterval SetTimeOut properly for the future
Stephen James
@sjames1958gm
Aug 17 2017 15:39
@tiagocorreiaalmeida Back to the white board?
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 15:40
by white board what do you mean?
Jason Luboff
@JLuboff
Aug 17 2017 15:40
Back to the drawing board would be another way of saying it..
Stephen James
@sjames1958gm
Aug 17 2017 15:41
@JLuboff :+1:
@tiagocorreiaalmeida drawing board, note pad, etc.
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 15:43
this is making no sense xd, anyway do you know any good article I could read about to get better understanding of what I need to do
Moisés Man
@moigithub
Aug 17 2017 15:44
pizarra
Tiago Correia
@tiagocorreiaalmeida
Aug 17 2017 15:44
aaa ok xd
not that kinda of "going back" xd
Joseph
@Big-jo
Aug 17 2017 16:05
please can someone explain this error, Uncaught TypeError: Cannot read property 'geometry' of undefined
at XMLHttpRequest.request.onload
Jason Luboff
@JLuboff
Aug 17 2017 16:05
@Big-jo You're trying to read a property from something that doesn't exist
Ankur sharma
@ankur1163
Aug 17 2017 16:09
i am using cssgrid in one of my project
my css is
.grid{
    margin:6px;
    background-color:green;
    color: orange;
    display: grid;
  grid-template-columns: 12% 25% 63%;
  grid-template-rows: 100%;
}
if you look
it doesnt give green color to top and bottom margin
Jake
@JakeDVirus
Aug 17 2017 16:10
This message was deleted
Ankur sharma
@ankur1163
Aug 17 2017 16:10
but it does fill it between grids
Jake
@JakeDVirus
Aug 17 2017 16:10
i was on the way of making a weather app.
there is some error popping out in console --> Cannot read property 'lon' of undefined
how come this being undefined of whose the lon is a property of.
https://codepen.io/neel111/pen/NvXNjN
Joseph
@Big-jo
Aug 17 2017 16:13
@JLuboff thanks,
CamperBot
@camperbot
Aug 17 2017 16:13
big-jo sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2154 | @jluboff |http://www.freecodecamp.com/jluboff
Afiur Rahman Fahim
@faahim
Aug 17 2017 16:36
@NeelDVirus I'm exactly on the same page where you are
Spent the whole day on it and finally figured out just this evening
Afiur Rahman Fahim
@faahim
Aug 17 2017 16:42

Nope, you did it in a different way.

Anyway, you have to call the function that gets the data from API within the function where you get the latitude and longitude data. If you don't do that and create a different function somewhere later in the code, then the function will complete running before your geoloc function finish running (which requires user to allow permission) and hence, it'll show undefined.

Hope that helps.
Jake
@JakeDVirus
Aug 17 2017 16:52
@faahim getting the data from API is the latter issue if that is the real issue i doubt. First issue is that Modernizr object is showing as undefined in the statement if(Modernizr.geolocation)
Afiur Rahman Fahim
@faahim
Aug 17 2017 16:55
@NeelDVirus I'm hearing about Mondernizr for the first time from you
looked it up and learned it's a detection library for HTML
But have you tried navigator.geolocation ?
It works flawlessly. Usually.
Jake
@JakeDVirus
Aug 17 2017 16:56
@faahim yeah it is just a feature detection small piece of javascript code of size about 1.2kb
Afiur Rahman Fahim
@faahim
Aug 17 2017 16:57
And that's what most people uses I guess?
Gersho
@Gersho
Aug 17 2017 16:57
navigator ? yeah
Jake
@JakeDVirus
Aug 17 2017 16:58
yeah using merely navigator.geolocation do works but its better to test whether geolocation API is supported or not
Afiur Rahman Fahim
@faahim
Aug 17 2017 16:58
had any luck with navigator?
kumquatfelafel
@kumquatfelafel
Aug 17 2017 16:58
@NeelDVirus You might have to import/require/access that library in some way before trying to use it.
Jake
@JakeDVirus
Aug 17 2017 16:58
@kumquatfelafel yeah i have imported the file in javascript console in codepen implicity
kumquatfelafel
@kumquatfelafel
Aug 17 2017 16:58
okay
Jake
@JakeDVirus
Aug 17 2017 16:59
@NeelDVirus and moreover i am digging into it in sublime text editor and checking the issue in browser console. Still the same thing, Modernizr is not defined
Moisés Man
@moigithub
Aug 17 2017 16:59
share codepen link ?
Afiur Rahman Fahim
@faahim
Aug 17 2017 17:00

Modernizr looks interesting. I'll try it out.

But I gotta go now. I passed my bedtime :(

Best of luck!
@faahim sure :D
Moisés Man
@moigithub
Aug 17 2017 17:02
check ur devtools console tab (NOT codepen console)
Gersho
@Gersho
Aug 17 2017 17:03
pen.js:19 Uncaught TypeError: Cannot read property 'lon' of undefined
you should check with a json.stringify and/or console log what the data you extracted looks like (i'll assume you got some data since it worked the first 18 lines)
Moisés Man
@moigithub
Aug 17 2017 17:04
add a lot of console.log
check what values ur variables have
ie: console.log(url)
https://fcc-weather-api.glitch.me//api/current?lon=:-75.7341811&lat=:-14.07546
if u go to that url.. u will see it doesnt work.. so ur url is wrong
fcc-weather-api.glitch.me//api/current?lon=:-75.7341811&lat=:-14.07546
remove those : @NeelDVirus
kumquatfelafel
@kumquatfelafel
Aug 17 2017 17:05
@NeelDVirus I'm not getting Modernizr as undefined in console.
What @moigithub said
Gersho
@Gersho
Aug 17 2017 17:06
https://codepen.io/Gersho/pen/YxWLBJ
i'd like to add that you can hold the mouse button on the +/- signs to add/remove a lot quickly, but i have no idea how i should do it, help plz :3
Jake
@JakeDVirus
Aug 17 2017 17:08
@kumquatfelafel yeah that is the issue here. why Mordenizr object is showed undefined
Moisés Man
@moigithub
Aug 17 2017 17:10
read above ? @NeelDVirus
Jake
@JakeDVirus
Aug 17 2017 17:11
@NeelDVirus @moigithub oh sorry i misread it. But it is showing undefined in my case. checking it out
Tomasz
@Tgralak
Aug 17 2017 17:13
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  var arr = str.split("");
  for (var i = 0; i<=str.length; i++) {
    if (str[i].toLowerCase() === str[i] && str[i+1].toUpperCase() === str[i+1]) {
      arr.splice(i,i+1, " ");

    }
  }
  return arr;
}

spinalCase('thisIsSpinalTap');
Hello! Can anone tell me why my code is throwing "cannot read toUpperCase of undefined"?
Jason Luboff
@JLuboff
Aug 17 2017 17:13
@Tgralak Becuase you're going beyond the length of the string
Tomasz
@Tgralak
Aug 17 2017 17:14
@JLuboff Ok, thank You very much :)
CamperBot
@camperbot
Aug 17 2017 17:14
tgralak sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
Jake
@JakeDVirus
Aug 17 2017 17:15
@moigithub @kumquatfelafel this is showing is my browser console in codepen page "Cannot read property 'lon' of undefined" now
Gersho
@Gersho
Aug 17 2017 17:15
@NeelDVirus it always had
Moisés Man
@moigithub
Aug 17 2017 17:16
did u removed the : from the url.. like posted above... ?? @NeelDVirus
lon comes from ur jquery getJSON data.. so first thing i would do.. is check if the url works...
console.log (url) (like posted above)
check that url on ur browser
Tomasz
@Tgralak
Aug 17 2017 17:18

@JLuboff

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  var arr = str.split("");
  for (var i = 0; i<str.length; i++) {
    if (arr[i].toLowerCase() === arr[i] && arr[i+1].toUpperCase() === arr[i+1]) {
      arr.splice(i,i+1, "");

    }
  }
  return arr;
}

spinalCase('thisIsSpinalTap');

Hey I changed my code to work on arrays, and now it throws error that it cant read "toLowerCase". I get the previous one, but can You explain this one?

Jake
@JakeDVirus
Aug 17 2017 17:18
@moigithub but while trying to check those code in my text editor it shows "modernizr" is undefined.
well this is the url i used which is suggested in FCC chanllenge https://fcc-weather-api.glitch.me/
@Gersho any suugestion ?
Tomasz
@Tgralak
Aug 17 2017 17:19
@JLuboff ok sorry i got it, my mistake
Moisés Man
@moigithub
Aug 17 2017 17:19
remove the : from ur url variable!!!!
@NeelDVirus
Jake
@JakeDVirus
Aug 17 2017 17:20
@moigithub shall i remove it from both places, before lon and lat
@moigithub this is what suggeted by FCC
"USAGE:
Use the endpoint: https://fcc-weather-api.glitch.me/. Use this endpoint to get the weather at a location. To prevent abuses this server accepts GET requests only, and serves only the route /api/current?lon=:longitude&lat=:latitude. Images links are included in the JSON under weather[0].icon. This is enough to complete the challenge. "
Moisés Man
@moigithub
Aug 17 2017 17:21
CHECK if u have build a correct url
pasting it on ur BROWSER
if it works.. then u should some values
Jake
@JakeDVirus
Aug 17 2017 17:22
@moigithub to verify the url i need to retrieve the value of longitude and latitude. any suggestion on this?
Moisés Man
@moigithub
Aug 17 2017 17:22
again... console.log(url)
run ur code..
copy the url string u get on ur BROWSER
Bradley Sands
@sandsbe
Aug 17 2017 17:23
thank you @cmccormack @sjames1958gm
CamperBot
@camperbot
Aug 17 2017 17:23
sandsbe sends brownie points to @cmccormack and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8332 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1152 | @cmccormack |http://www.freecodecamp.com/cmccormack
Jake
@JakeDVirus
Aug 17 2017 17:23
@moigithub removing the semicolon did no good
Gersho
@Gersho
Aug 17 2017 17:23
@NeelDVirus try making it first with navigator.geoloc, then upon success try with the method you wanted to try (the challenges do invite you to use whatever library you want)
Jake
@JakeDVirus
Aug 17 2017 17:24
@moigithub checking out the url
Moisés Man
@moigithub
Aug 17 2017 17:24
the ERROR u have when u building ur url string is u have some extra :
like posted above @NeelDVirus
fixing that.. ur getJSON will return some data
ADD more console.log to check those data structure.. before adding more code
this is ur current code
function success(position){
var url = "https://fcc-weather-api.glitch.me//api/current?lon=`:`" + position.coords.longitude + "&lat=:" + position.coords.latitude;
$.getJSON(url, functForTemp);
u need to FIX THOSE:.. remove the :
This message was deleted
Jake
@JakeDVirus
Aug 17 2017 17:25
@moigithub yeah i removed :but did no good and so i again placed it there. and i dont think the semicolon is the issue
i am trying to verify the url somehow
Jake
@JakeDVirus
Aug 17 2017 17:26
@moigithub check this link https://fcc-weather-api.glitch.me/
@moigithub Damn my apology. thanks for pointing this out man
CamperBot
@camperbot
Aug 17 2017 17:27
neeldvirus sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3594 | @moigithub |http://www.freecodecamp.com/moigithub
Jake
@JakeDVirus
Aug 17 2017 17:28
@moigithub so now url works. now?
Moisés Man
@moigithub
Aug 17 2017 17:29
before work with data.. first u need to know the (json) data structure
Jake
@JakeDVirus
Aug 17 2017 17:30
@Gersho that will again be a long way :D i am being a lazy ass now :D
Moisés Man
@moigithub
Aug 17 2017 17:30
function functForTemp(data, status, xhr){
console.log(data)
and check on ur browser console
u will notice there are no
+ parsedText.coords.lon +
property
Gersho
@Gersho
Aug 17 2017 17:33
@NeelDVirus well you don't have to complete it right now, i was 75% done on multiple challenges before submitting the first one
so go left, right, as long as you learn along the way
https://codepen.io/Gersho/pen/YxWLBJ
need opinion, also tell me if you find bug (i managed to find what i needed with .on("mousedown", )
Jake
@JakeDVirus
Aug 17 2017 17:34
@Gersho my curiosity wont allow me to leave the puzzle unsolved :D
Gersho
@Gersho
Aug 17 2017 17:35
i'm more like starting to read the doc for problem A, find info about B and go test it on another thing xD
now i'm trying to make the pomodoro a bit more beautifull but...i suck at css
Jake
@JakeDVirus
Aug 17 2017 17:37
@NeelDVirus i might not be the suitable person to give the opinion as i havn't came across this challenge yet
but yeah your css style looks cool man
Gersho
@Gersho
Aug 17 2017 17:38
you think so ? cool
Jake
@JakeDVirus
Aug 17 2017 17:42
@Gersho yeah it is cool indeed
Gersho
@Gersho
Aug 17 2017 17:43
i don't have much confidence in design choices so \o/
Joseph
@revisualize
Aug 17 2017 17:43
Hey.
Jason Luboff
@JLuboff
Aug 17 2017 17:44
Hey.
Jake
@JakeDVirus
Aug 17 2017 17:44
@Gersho neither do i. i will delve into designing soon
Gersho
@Gersho
Aug 17 2017 17:45
i won't, i'm design blind that's a real life fact
Jake
@JakeDVirus
Aug 17 2017 17:46
@Gersho there are many platforms available to deploy designing in your work. like materialize, bootstrap and others.. i prefer materialize
and font faces etc etc
Gersho
@Gersho
Aug 17 2017 17:47
no i mean, like when you're supposed to match colors in a decent way
that kind of stuff
but for the pomodoro i think i only need to change a bit the buttons and it should look finished
Jake
@JakeDVirus
Aug 17 2017 17:55
@Gersho yeah color combination is also not of my area to master. i am really bad at it :D
@Gersho send the link of your portofolio
Jason Luboff
@JLuboff
Aug 17 2017 17:56
@Gersho @NeelDVirus https://coolors.co/ Here's a neat site to help generating colors that go together
Jake
@JakeDVirus
Aug 17 2017 17:57
@JLuboff Thanks man. But i think its only free for 3months
CamperBot
@camperbot
Aug 17 2017 17:57
neeldvirus sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2155 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Aug 17 2017 17:57
@NeelDVirus No, its free
The 3 months is for Skillshare, which I don't know what that is
You just click the blue button "Start the Generator, it's free!"
You don't have to sign up to use it
Bradley Sands
@sandsbe
Aug 17 2017 17:59
What's free? I love free stuff. The free PLuralSight has been decent so far.
Jason Luboff
@JLuboff
Aug 17 2017 17:59

@sandsbe

@Gersho @NeelDVirus https://coolors.co/ Here's a neat site to help generating colors that go together

Gersho
@Gersho
Aug 17 2017 18:01
@JLuboff i'll have a look thanks
CamperBot
@camperbot
Aug 17 2017 18:01
gersho sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
Jake
@JakeDVirus
Aug 17 2017 18:01
@sandsbe pluralsight is free? i think its paid stuff
CamperBot
@camperbot
Aug 17 2017 18:01
:star2: 2156 | @jluboff |http://www.freecodecamp.com/jluboff
Bradley Sands
@sandsbe
Aug 17 2017 18:01
Nice.
Dovydas Stirpeika
@Giveback007
Aug 17 2017 18:01
anyone here has done the voting app?
Jason Luboff
@JLuboff
Aug 17 2017 18:01
@Giveback007 I have
Jake
@JakeDVirus
Aug 17 2017 18:01
@JLuboff oh thats great man
Bradley Sands
@sandsbe
Aug 17 2017 18:02
PluralSight is paid. BUT, if you sign up for Microsoft viz studios (free), you then get 3 free months of PluralSight.
It's a free sh*t 2-step
Dovydas Stirpeika
@Giveback007
Aug 17 2017 18:02
@JLuboff do you have some tips before I get started?
@JLuboff like some reading resources I don't even know where to start for user authentication
Gersho
@Gersho
Aug 17 2017 18:03
@NeelDVirus
i tried looking at your weather app a bit closer, i think your getJSON is way too complicated, so i went with
  function success(position){
    var url = "https://fcc-weather-api.glitch.me//api/current?lon=" + position.coords.longitude + "&lat=" + position.coords.latitude;
    $.getJSON(url, function (data){
      $loc.html(JSON.stringify(data));
    });
  }
Jake
@JakeDVirus
Aug 17 2017 18:03
@sandsbe oh i see. Torrent has always came to rescue when i needed anything paid stuff
Gersho
@Gersho
Aug 17 2017 18:03
you only need to remove the stringify and use data variable
Gulsvi
@gulsvi
Aug 17 2017 18:04
function updateInventory(arr1, arr2) {
  var newInv = {};
  arr1.forEach(shipment => newInv[shipment[1]] = shipment[0]);
  arr2.forEach(shipment => newInv[shipment[1]] = newInv[shipment[1]] + shipment[0] || shipment[0]);
  return Object.keys(newInv).sort().map(val => [newInv[val], val]);
}

updateInventory(curInv, newInv);
Is there a one-liner to convert a 2d array to an object so I don't need that var newInv = {}?
Jake
@JakeDVirus
Aug 17 2017 18:04
@Gersho whoaa checking it out
:o:
Gersho
@Gersho
Aug 17 2017 18:04
@JLuboff like some reading resources I don't even know where to start for user authentication
reading ressources ? try https://zealdocs.org plenty of doc available offline and with instant search
@Giveback007 failed my quote
Jason Luboff
@JLuboff
Aug 17 2017 18:05
@Giveback007 I used PassportJS with the Github Strategy for authentication. I personally went through the Clementine tutorial (there's two, first was the basic tutorial, and they have a second one that adds authentication). I found that overall Clementine didn't work out for me (I ended up building things myself) but it gave me a starting point/a bit better understanding of things.
Jake
@JakeDVirus
Aug 17 2017 18:07
@Gersho my head is spinning. what a mess :D
Jason Luboff
@JLuboff
Aug 17 2017 18:07
@Giveback007 Its a big step going from the API projects to the Dynamic Web apps. They just kind of throw you over board :D
Gersho
@Gersho
Aug 17 2017 18:07
@NeelDVirus i removed everything that didn't seem mandatory (xhr, etc)
Jake
@JakeDVirus
Aug 17 2017 18:08
@Gersho xhr is mandatory i guess. xhr is the XMLHttpRequest object
Dovydas Stirpeika
@Giveback007
Aug 17 2017 18:09
@Gersho I have zeal, it's great, I just didn't know where in there to look
Jason Luboff
@JLuboff
Aug 17 2017 18:09
@Giveback007 This is my Voting App: https://votingapp-jluboff.herokuapp.com/ it's by no means perfect, or maybe even good :joy: and since then I've learned several things that I should go back and implement but for the time being, it gets the job done
Gersho
@Gersho
Aug 17 2017 18:09
well my call works and pulls out the object (as a ugly string, because i was lazy)
@NeelDVirus the url you use for the call is valid, so the call itself should work, try having a console.log at the first line of the getJSON's callback
Dovydas Stirpeika
@Giveback007
Aug 17 2017 18:11
@JLuboff tnx, time to start reading (ugh...) :smile:
CamperBot
@camperbot
Aug 17 2017 18:11
giveback007 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2157 | @jluboff |http://www.freecodecamp.com/jluboff
Jake
@JakeDVirus
Aug 17 2017 18:12
@Gersho i cant really use my brain anymore on it today. going to hit this part tomorow. going to learn something else relevant :D
Gersho
@Gersho
Aug 17 2017 18:12
if the console log gets called, it means the getJSON worked, and if you still have an error after that, it means you're not aiming properly for the object you want (so it returns undefined) @NeelDVirus
Jason Luboff
@JLuboff
Aug 17 2017 18:12
@Giveback007 It took me probably a solid.. month? Between doing my last API project and beginning my Voting app. It was very daunting at first. But once I actually sat down and started working on it, it wasn't too bad. Learned a lot
Jake
@JakeDVirus
Aug 17 2017 18:13
@Gersho when paste every code in my text editor and run it in browser then it shows mordenizr is undefined
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:13
can any one please tell me the font awesome icons arent appearing on my page http://akodia488.github.io
Jake
@JakeDVirus
Aug 17 2017 18:14
and i think testing in pure text editor is more reliable
Dovydas Stirpeika
@Giveback007
Aug 17 2017 18:14
@JLuboff yeah, it sounds like it's the same with every one of these learning curves. It was a pain in the ass to get started with React also. Hopefully I'll fare better this time.
Gersho
@Gersho
Aug 17 2017 18:14
@NeelDVirus because you added mordenizr in the codepen interface, so it's not as a <script src ??
Jason Luboff
@JLuboff
Aug 17 2017 18:14
@akodia488 Looking in the console.. Blocked loading mixed active content “http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0”[Learn More]
Stephen James
@sjames1958gm
Aug 17 2017 18:14
@akodia488 loading them over http and your site is https
Jason Luboff
@JLuboff
Aug 17 2017 18:15
@akodia488 Great looking site btw :+1:
Gersho
@Gersho
Aug 17 2017 18:15
@NeelDVirus
<script src='https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js'></script>
in codepen, when exporting your work, you should EXPORT it, not copy/paste it :)
Jason Luboff
@JLuboff
Aug 17 2017 18:16
@Giveback007 Good luck :+1:
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:16
can any one please tell me why the font awesome icons arent appearing on my page http://akodia488.github.io
Gersho
@Gersho
Aug 17 2017 18:16
yeah chill out for a sec no need to spam
Stephen James
@sjames1958gm
Aug 17 2017 18:17
@akodia488 your fontawesome.min.js is referencing http:// which wont load in https site
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:17
@sjames1958gm so what should i do
Gersho
@Gersho
Aug 17 2017 18:17
yeah it's like spamming a billion errors in the console
put a s on it
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:18
@Gersho i fuckin love you bro
Gersho
@Gersho
Aug 17 2017 18:18
@akodia488
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'>
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:20
cool , let me use this
@Gersho not working bro
i actually have fontawesome.min.css in a directory on the server
on the web directory
but it still aint showing those signs
u can download it to your computer and see
Gersho
@Gersho
Aug 17 2017 18:21
then link it as relative, not absolute, that way it won't be http
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:22
@Gersho so i have to the css styling?
wow...
Gersho
@Gersho
Aug 17 2017 18:22
no
i mean
Emmanuel Akodia
@akodiaemma
Aug 17 2017 18:22
oh
what u mean
BrianWilliams28
@BrianWilliams28
Aug 17 2017 18:24
hey guys, could someone give me a tip on how to fix my code for the Convert HTML Entities algorithm? Here's what I have so far.
function convertHTML(str) {
  // &colon;&rpar;
   var re = /[&<>"']/g;
  var test = re.test(str);
  var newStr = '';

 for (var i = 0; i < str.length; i++) {
   if (test) {
   switch (str[i]) {
     case '&':
       newStr = str.replace(/&/g, '&amp;');
       break;
     case '<':
      newStr = str.replace(/</g, '&lt;');
       break;
     case '>':
       newStr = str.replace(/>/g, '&gt;');
       break;
     case '"':
       newStr = str.replace(/"/g, '&quot;');
       break;
     case "'":
       newStr = str.replace(/'/g, '&apos;');
       break;
                 }
     return newStr;
   }
   else return str;
 }
}

convertHTML("Dolce & Gabbana");
Gersho
@Gersho
Aug 17 2017 18:25

instead of doing href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css' you do

href='css/style.css' (well not style.css, but you link to your file, using the filepath relative to where index.html is, rather than grab it via http/https

Jason Luboff
@JLuboff
Aug 17 2017 18:27
@BrianWilliams28 No need for the if/else statement. And move return newStr; outisde your loop
Gary Siu
@GarySiu
Aug 17 2017 18:27
@BrianWilliams28 String.protype.replace already searches through the string. Don't need to iterate.
If it doesn't find anything it will just return the original string
BrianWilliams28
@BrianWilliams28
Aug 17 2017 18:28
@JLuboff problem is if i dont have an if / else statement it wont solve the last two arguments
@GarySiu can i write a custom replace function like this? str.replace(function(substr, val) { });
Gary Siu
@GarySiu
Aug 17 2017 18:31
@BrianWilliams28 You Could but why would you?
It will break any other code that uses the default function.
BrianWilliams28
@BrianWilliams28
Aug 17 2017 18:32
@GarySiu because i can't put all the cases of what to replace in one line of replace can i?
Gary Siu
@GarySiu
Aug 17 2017 18:32
@BrianWilliams28 You can chain the methods
BrianWilliams28
@BrianWilliams28
Aug 17 2017 18:32
can you give me an example?
Gary Siu
@GarySiu
Aug 17 2017 18:33
str.replace(/&/g, '&amp;').replace(/</g, '&lt;')
Basically it takes the return of the first method and then calls the next method
Gersho
@Gersho
Aug 17 2017 18:34
the left replace is called first in this case ? (just trying to follow ^ ^)
Stephen James
@sjames1958gm
Aug 17 2017 18:35
@akodia488 Inside of the fontawesome file it refers to http:// URLs which won't work from https://
You need a new file or edit that one to remove all the http:
Gary Siu
@GarySiu
Aug 17 2017 18:35
@Gersho Yup it evaluates left to right
Also with JS you can use whitespace to make things a read a bit more nicely:
str
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
Gersho
@Gersho
Aug 17 2017 18:36
whitespace only ? (not end of line ? (ENTER))
Gary Siu
@GarySiu
Aug 17 2017 18:37
Newlines are whitespace :)
Gersho
@Gersho
Aug 17 2017 18:37
okies, thanks @GarySiu
looks like cookie bot is on strike
stealing all our cookies
Gary Siu
@GarySiu
Aug 17 2017 18:37
It's ok, I'm full
Gersho
@Gersho
Aug 17 2017 18:37
there's always room for cookies, they don't go in the stomach, they go in the soul ;)
Gary Siu
@GarySiu
Aug 17 2017 18:38
It's good practise to end your method chain with ; so JS knows there aren't more method calls to come or so you don't accidentally do it further down your code
Gersho
@Gersho
Aug 17 2017 18:39
i use plenty of those
Gary Siu
@GarySiu
Aug 17 2017 18:39
:+1:
Daniel Narilton
@spaganger
Aug 17 2017 18:42
I'm trying to skip x array items in a loop. For instance, given array [3, 5, 6, 7, 9, 10, 11] and x = 2, the result should be:[3, 7, 11]. Is there anything wrong with my code?
function printNeatly(array) {
    var newArray = [];
    var num = 2;
    if (num) {
        newArray[0] = array[0];

        newArray.push(array[1 + num])
        newArray.push(array[4 + num]);
    }
    return newArray;
}
Gersho
@Gersho
Aug 17 2017 18:43
if num ? if num what
BrianWilliams28
@BrianWilliams28
Aug 17 2017 18:44
@GarySiu thank you sir
CamperBot
@camperbot
Aug 17 2017 18:44
brianwilliams28 sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 440 | @garysiu |http://www.freecodecamp.com/garysiu
Daniel Narilton
@spaganger
Aug 17 2017 18:44
if num is true?
Stephen James
@sjames1958gm
Aug 17 2017 18:44
@Vigariuoluvi This will only work with one value of num and one size array
Gersho
@Gersho
Aug 17 2017 18:45
@Vigariuoluvi true ? but it's 2
Gary Siu
@GarySiu
Aug 17 2017 18:45
2 is true :)
@Vigariuoluvi I don't see a loop in your code?
Daniel Narilton
@spaganger
Aug 17 2017 18:45
@sjames1958gm I see. how can I fix it?
Gersho
@Gersho
Aug 17 2017 18:45
on an unrelated note i would suggest having num as an argument, can re-use code that way
@GarySiu oh ok
Stephen James
@sjames1958gm
Aug 17 2017 18:46
@Vigariuoluvi Use a loop of some kind and passing num as an argument
for (var i = 0; i < array.length i += num + 1)
Daniel Narilton
@spaganger
Aug 17 2017 18:46
@GarySiu I tried coming up with two for loops for it earlier but it didn't work
Gary Siu
@GarySiu
Aug 17 2017 18:48
Stephen has basically solved it for you. Missed a ; though :)
Gersho
@Gersho
Aug 17 2017 18:48
how about slicing it into smaller num+1 length arrays [3,5,6] [7,9,10][11] and then pick the first value of each array ?
Daniel Narilton
@spaganger
Aug 17 2017 18:49
@Gersho i thought of that also. but will it get any slower if i use many arrays?
Gersho
@Gersho
Aug 17 2017 18:49
i have no idea
Joel Y.
@zapcannon99
Aug 17 2017 18:51
I think Stephen's got the best solution
Gary Siu
@GarySiu
Aug 17 2017 18:54
It might make more sense if you think of it in terms of for(variable declaration; condition; step)
Most the time you want step to only go up by 1, so you use something like i++
Daniel Narilton
@spaganger
Aug 17 2017 18:55
@zapcannon99 Yes. He thought me a new trick! =)
Gary Siu
@GarySiu
Aug 17 2017 18:55
But here you want to step by a greater amount + 1
viteresa
@viteresa
Aug 17 2017 19:08
Hello fellow campers! I am studying Javascript Objects. Sometimes I see the objects properties in the left (the key) written within quotation marks and sometimes dont. I am confused....
Joel Y.
@zapcannon99
Aug 17 2017 19:10

someObject.someProperty is the same thing as writing someObject["someProperty"]

However, be aware that someObject[someProperty] is NOT the same as someObject.someProperty since someObject[someProperty] is trying to access a property with the value that is stored in someProperty.

Gary Siu
@GarySiu
Aug 17 2017 19:11
@viteresa quotation marks are actually "string literals". It means I'm looking for a value matching the key with the string with the content 'blah'.
Without the quotation marks it references the current contents of a variable
Joel Y.
@zapcannon99
Aug 17 2017 19:11
:point_up:
Dovydas Stirpeika
@Giveback007
Aug 17 2017 19:12
hey is mongoDB open source?
Joel Y.
@zapcannon99
Aug 17 2017 19:12
I think so
Dovydas Stirpeika
@Giveback007
Aug 17 2017 19:12
I went on their site and there's all these pricing options
Guderian Raborg
@hypercuber
Aug 17 2017 19:12
How do I make the snake have let say 5 squares?
https://codepen.io/hypercuber/pen/rzpVGJ?editors=0010
Jason Luboff
@JLuboff
Aug 17 2017 19:13
@Giveback007 Use mlab.com for a free 500gb database (as many as you want as far as I know)
Dovydas Stirpeika
@Giveback007
Aug 17 2017 19:14
oh goody
Gary Siu
@GarySiu
Aug 17 2017 19:15
@Giveback007 The sourcecode is availible and it's free to run on your own machine. They're just offering hosted services.
Dovydas Stirpeika
@Giveback007
Aug 17 2017 19:15

@Giveback007 Use mlab.com for a free 500gb database (as many as you want as far as I know)

just to be sure you mean 500mb right? :smile:

@GarySiu @JLuboff tnx
CamperBot
@camperbot
Aug 17 2017 19:16
giveback007 sends brownie points to @garysiu and @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @garysiu |http://www.freecodecamp.com/garysiu
:star2: 2158 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Aug 17 2017 19:22
@Giveback007 Sorry, ya mb
viteresa
@viteresa
Aug 17 2017 19:31
@Joel Y. and @GarySiu : Thank you both!
CamperBot
@camperbot
Aug 17 2017 19:31
viteresa sends brownie points to @joel and @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 442 | @garysiu |http://www.freecodecamp.com/garysiu
:warning: @joel's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Bradley Sands
@sandsbe
Aug 17 2017 19:45
$(".box").click(function() {
    console.log('click works')
    if (checkSquare(this.id) && Game.player === "X") {
      $("#" + this.id).html("<p>X</p>").addClass("box-x");
      addCount();
      cpuOpen();
      //pushX (this.id);
      //checkX();
    } else if (checkSquare(this.id) && Game.player === "O") {
      console.log('getting there...');
      $("#" + this.id).html("<p>O</p>").addClass("box-o");
      addCount();
      cpuOpen();
    }
  });
can anyone see why my top IF statement would work but my ELSE IF doesn't?
There should be identical.
Mariusz Klimek
@tarnos12
Aug 17 2017 20:14

Any ideas why my getX() method takes so much time to run? Could it be because it is an object returned from a function that has access to private variables?

https://i.gyazo.com/4098ea3670cd674a4bfce0d8502fcf35.png

Bradley Sands
@sandsbe
Aug 17 2017 20:14
Found the issue
Mariusz Klimek
@tarnos12
Aug 17 2017 20:15
or is it just a coincidence
getY() runs at 0.3ms compared to getX() 11.3ms, it has to be something with the way my variable is created?
christopher clarke
@chrisdclarke
Aug 17 2017 21:13
hello everyone.. greetings from vancouver
Jean-Paul Sauve
@jp-sauve
Aug 17 2017 21:27
var Greeting = function(city) {
    var here = city;
    this.greetFrom = function() {
         return "Hello to you! Greetings from " + here + "!";
    };
};
var myGreeting = new Greeting('London');
myGreeting.greetFrom();
alpox
@alpox
Aug 17 2017 21:31
@tarnos12 Did you try to just return x; and measure again?
Ibrokola
@Ibrokola
Aug 17 2017 21:33
Hello, greetings from Edmonton... How's the tech market doing in Vancouver @christopher clarke
Mariusz Klimek
@tarnos12
Aug 17 2017 21:33
@alpox I will try it tomorrow, that might be the case. Thanks
CamperBot
@camperbot
Aug 17 2017 21:33
tarnos12 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1302 | @alpox |http://www.freecodecamp.com/alpox
kumquatfelafel
@kumquatfelafel
Aug 17 2017 21:54
@tarnos12 Note that there are differences between the two functions. In one, you're simply returning a variable. In the other, you're performing subtraction and division, then returning the result. I would test whether return x on it's own would similarly be significantly slower before coming to a conclusion one way or another. You want to eliminate whatever differences you can so that what you're testing is... well... what you want to test. :p

oops!

What @alpox said

christopher clarke
@chrisdclarke
Aug 17 2017 22:23
hey edmonton,, things are pretty good !!!...
Ronique Ricketts
@RoniqueRicketts
Aug 17 2017 22:42
anyone here familiar with codeigniter?
BrianWilliams28
@BrianWilliams28
Aug 17 2017 22:53
why doesn't this work?
var toLowerCase = str.replace(/[A-Z]g/, '$&'.toLowerCase());
Jean-Paul Sauve
@jp-sauve
Aug 17 2017 22:59
@BrianWilliams28 you can't use a reserved name as a variable?
that's just a guess. At best it's very bad form
also, the g is after the last slash iirc
it's a flag, not part of the regex
cowCrazy
@cowCrazy
Aug 17 2017 23:01
@BrianWilliams28 not sure what you try to do, but if you use 'g' as a 'global' flag it should be like this /[A-Z]/g
Jean-Paul Sauve
@jp-sauve
Aug 17 2017 23:01
what do you expect to happen when you lower-case a symbol?
Margaret
@Margaret2
Aug 17 2017 23:02
yeah, this works fine var x = 'hello'.replace(/[a-z]/g, '$'.toLowerCase())
although .toLowerCase is completely unnecessary because there's no lowercase version of $ lol
Moisés Man
@moigithub
Aug 17 2017 23:08
var toLowerCase = str.replace(/[A-Z]/g, x=>x.toLowerCase());
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:14
@moigithub thank you this works, but could you please explain why? is this an arrow function? how does it work?
CamperBot
@camperbot
Aug 17 2017 23:14
brianwilliams28 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3596 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
Aug 17 2017 23:14
@BrianWilliams28 why don't you use var toLowerCase = str.toLowerCase();?
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:15
@Chrono79 because im dumb and i forgot about that function lol
@Chrono79 thank you
CamperBot
@camperbot
Aug 17 2017 23:15
brianwilliams28 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4526 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 17 2017 23:16
no problem
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:19
how would i write a regular expression to test for whitespaces, and these two characters [-_]
/(\s)([-_])/g doesnt seem to work
kumquatfelafel
@kumquatfelafel
Aug 17 2017 23:21
@BrianWilliams28 that will look for whitespace followed by - or _.
cowCrazy
@cowCrazy
Aug 17 2017 23:21
@BrianWilliams28 can you post your desired match string?
also you can play around with https://regex101.com very useful
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:22
yeah im using that site
but im still pretty new to it
@cowCrazy "AllThe-small Things" = "all-the-small-things"
basically i would want to match white spaces, - and _
kumquatfelafel
@kumquatfelafel
Aug 17 2017 23:23
If I wanted,e.g., a regex that looks for a or y, I would say
/a|y/g
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:23
and then convert them to hyphens
cowCrazy
@cowCrazy
Aug 17 2017 23:24
@BrianWilliams28 /[ \-_]/g something like this maybe?
kumquatfelafel
@kumquatfelafel
Aug 17 2017 23:24
Or, /[ay]/g
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:25
@cowCrazy yes thanks
CamperBot
@camperbot
Aug 17 2017 23:25
brianwilliams28 sends brownie points to @cowcrazy :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @cowcrazy |http://www.freecodecamp.com/cowcrazy
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:25
@kumquatfelafel ty
CamperBot
@camperbot
Aug 17 2017 23:25
brianwilliams28 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 616 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
cowCrazy
@cowCrazy
Aug 17 2017 23:27
@BrianWilliams28 the '-' needed to be escaped with '-' cause otherwise it is a range of chars and not the char itself, and whitespace in regexp is simply a whitespace
BrianWilliams28
@BrianWilliams28
Aug 17 2017 23:27
@cowCrazy or \s right?
Jean-Paul Sauve
@jp-sauve
Aug 17 2017 23:28
or just list the "-" as the first or last character, and it will be interpreted as a hyphen
cowCrazy
@cowCrazy
Aug 17 2017 23:31
@jp-sauve :+1: , @BrianWilliams28 '\s' is more than just simple ' ' it is all whitespace cahrs, so if you wanna catch all of them then use it like '\s'