These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Jul 2017
Joseph
@revisualize
Jul 10 2017 00:06
@John-freeCodeCamp
image.png
@John-freeCodeCamp I don't understand your challenges with the lesson.
@John-freeCodeCamp It's just changing two lines.
@John-freeCodeCamp All outlined in the instructions
John
@AnonymousLords
Jul 10 2017 00:09
@revisualize It worked now, the issue was that it wasn'
t working until the page was refreeshed.
thx anyways @revisualize
CamperBot
@camperbot
Jul 10 2017 00:09
john-freecodecamp sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4333 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 10 2017 00:09
@John-freeCodeCamp Cool. Glad you got it workings.
@John-freeCodeCamp Sometimes FCC has issues with multiple changes and code executes.
@John-freeCodeCamp But, I've ran into that issue with Codewars too.
John
@AnonymousLords
Jul 10 2017 00:11
Yeah, i was doing the exact code that people were telling me and nothing. Finnaly @saifsmailbox98 told me to refresh the page, and it worked :D
Joseph
@revisualize
Jul 10 2017 00:15
@John-freeCodeCamp something to be mindful of in the future
Diego Mayer
@Chrono79
Jul 10 2017 00:21

@Tom-Gause

  case 1: answer=("alpha");

You don't need the () there

@revisualize :wave: Glad to see you finally dusted off your CW account :P
Joseph
@revisualize
Jul 10 2017 00:29
@Chrono79 Just a few lessons
Diego Mayer
@Chrono79
Jul 10 2017 00:29
:+1:
silver537
@silver537
Jul 10 2017 00:33
What is CW?
Oh
Code wars
My bad hehehe
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:42
function palindrome(str) {
  var regex = /[^0-9a-z]/gi; // Regular expression to apply, all characters not in the braces (0 through 9 and a through z, case-insensative matching, a global search.)
  var regexedStr = str.toLowerCase().replace(regex, ''); // Covert the string to lower case and apply the regex.
  var reversedStr = regexedStr.split('').reverse().join('');  // Reverse the string.
  return reversedStr === str; // Compare and return true or false.
}
palindrome("_eye");
I’m working on this challenge however the underscore isn’t getting removed with the regular expression for some reason. Any ideas on what I’m doing wrong?
Christopher McCormack
@cmccormack
Jul 10 2017 00:43
@nsuchy shouldn't you be comparing to regexedStr?
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:44
It compared reversed string to str, it takes the regex and makes the regexed string, the reversed string is created from the regexed string
It was split up to make the code easier to read and debug
Christopher McCormack
@cmccormack
Jul 10 2017 00:44
@nsuchy just read it again
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:44
Is the regular expression wrong?
Christopher McCormack
@cmccormack
Jul 10 2017 00:45
@nsuchy in your return, str has all the spaces and special characters in it
try comparing to regexedStr
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:45
then it’s not reversed
which is why I reverse in the next string
but reversed is equal to the regexed string, it’s just flipped backwards.
Christopher McCormack
@cmccormack
Jul 10 2017 00:46
you shouldn't care about str anymore after you parse it with regex
you have a perfectly good variable to compare against, just try it out
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:47
function palindrome(str) {
  var regex = /[^0-9a-z]/gi; // Regular expression to apply, all characters not in the braces (0 through 9 and a through z, case-insensative matching, a global search.)
  var regexedStr = str.toLowerCase().replace(regex, '').split('').reverse().join(''); // Covert the string to lower case and apply the regex.
  return regexedStr === str; // Compare and return true or false.
}
palindrome("_eye");
really wish this code formatting knew what a commment was
Christopher McCormack
@cmccormack
Jul 10 2017 00:48
your previous code was closer. Take the previous code and in your return replace str with regexedStr
you don't want to compare your reversed string with the original string, it's not going to have any of the special characters you removed in the regex
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:51

function palindrome(str) {

  var regex = /[^0-9a-z]/gi; // Regular expression to apply, all characters not in the braces (0 through 9 and a through z, case-insensative matching, a global search.) 

  var regexedStr = str.toLowerCase().replace(regex, '').split('').reverse().join(''); // Covert the string to lower case and apply the regex. Then reverse the string.

  return regexedStr === str; // Compare and return true or false.
}
palindrome("_eye");
That’s my current code
What needs to change?
Christopher McCormack
@cmccormack
Jul 10 2017 00:52
@nsuchy go back to your first code snippet you pasted and read my responses
Diego Mayer
@Chrono79
Jul 10 2017 00:53
@nsuchy @cmccormack already told you you shouldn't use str in the return line, str still has non-alphanumeric chars
If you apply toLowerCase first, the i flag of your regex isn't needed either
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:54
function palindrome(str) {

  var regex = /[^0-9a-z]/gi; // Regular expression to apply, all characters not in the braces (0 through 9 and a through z, case-insensative matching, a global search.) 

  str = str.toLowerCase().replace(regex, '');

  var regexedStr = str.toLowerCase().replace(regex, '').split('').reverse().join(''); // Covert the string to lower case and apply the regex. Then reverse the string.

  return regexedStr == str; // Compare and return true or false.
}
palindrome("_eye”);
I see what you’re saying now
That worked
was only adjusting str and both strings needed to be adjusted
Christopher McCormack
@cmccormack
Jul 10 2017 00:55
@nsuchy it does but now you're doing more work than you had in your first post
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:55
:)
Diego Mayer
@Chrono79
Jul 10 2017 00:55
@nsuchy reverse str once you "cleaned" it
Nathaniel Suchy
@nsuchy
Jul 10 2017 00:55
Thanks @cmccormack @Chrono79
CamperBot
@camperbot
Jul 10 2017 00:55
nsuchy sends brownie points to @cmccormack and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1016 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 4473 | @chrono79 |http://www.freecodecamp.com/chrono79
Christopher McCormack
@cmccormack
Jul 10 2017 00:55
@nsuchy :thumbsup:
Diego Mayer
@Chrono79
Jul 10 2017 00:55
:+1:
arsovskidario
@arsovskidario
Jul 10 2017 02:07
I downloaded sublime 3 to switch from codepen.io and the build functino isnt worknig.I typed in basic html code and it opens a google.com website not the website it's supposed to open.
http://prntscr.com/ftoh49 code
https://prnt.sc/ftoh78 after CTRL+B
Need help urgent getting aggressive
Frank McCroy
@fmccroy
Jul 10 2017 02:10
Not sure if it matters, but I thought it’s !DOCTYPE html
arsovskidario
@arsovskidario
Jul 10 2017 02:10
no
the build doesnt work
it works on subline 2
idk whats the probelm
Frank McCroy
@fmccroy
Jul 10 2017 02:14
I typed out a bunch of code in Sublime 3.. how do you normally build it or run it?
arsovskidario
@arsovskidario
Jul 10 2017 02:14
ctrl +b
but u need to enable it first
Frank McCroy
@fmccroy
Jul 10 2017 02:15
I see.. it keeps saying “no build system”.. how do I enable it?
arsovskidario
@arsovskidario
Jul 10 2017 02:15
heres a link
It's all explained
This was the first method i tried
mauriciodeleonc
@mauriciodeleonc
Jul 10 2017 02:17
function titleCase(str) {

  //first set all the string to "lower case" and then split it by its spaces

  var separate = str.toLowerCase().split(" ");
  console.log(separate);

  //counter to go between words in the array
  for (var i = 0; i <= separate.length; i++) {

      separate[i] = separate[i].charAt(0).toUpperCase() + separate[i].substring(1);
      console.log(separate[i]); 

  }

  str = separate.join(" ");
  console.log(str);
  return str;
}

titleCase("I'm a little tea pot");
hi guys
this gives me "separate[i] is not defined"
any idea why?
Frank McCroy
@fmccroy
Jul 10 2017 02:18
@mauriciodeleonc You may be trying to read past the end of the array with i <= separate.length. Using i < separate.length might work better.
mauriciodeleonc
@mauriciodeleonc
Jul 10 2017 02:19
yep
that was it
thanks @fmccroy
CamperBot
@camperbot
Jul 10 2017 02:19
mauriciodeleonc sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 374 | @fmccroy |http://www.freecodecamp.com/fmccroy
arsovskidario
@arsovskidario
Jul 10 2017 02:19
@fmccroy did you try sublime ?
Frank McCroy
@fmccroy
Jul 10 2017 02:20
@arsovskidario I looked at your link, but I’m not sure what I’m supposed to be installing or why?
arsovskidario
@arsovskidario
Jul 10 2017 02:20
or is my computer just retarded
open console in sublime
ctrl +`
and type in the link
import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
in the console and press enter
thats the build plugin
Frank McCroy
@fmccroy
Jul 10 2017 02:21
@arsovskidario I have Sublime 3, but haven’t tried doing anything with it yet. I’ve always used FCC or CodePen for stuff
arsovskidario
@arsovskidario
Jul 10 2017 02:21
FCC?
freecodecamp
XD
Frank McCroy
@fmccroy
Jul 10 2017 02:23
@arsovskidario I ran what you asked from the console, and it gave a few warnings, and still does nothing when I try to build.
@arsovskidario What is supposed to happen when I use the build command? I can double click the file in my browser and it displays. Building will display it automatically?
arsovskidario
@arsovskidario
Jul 10 2017 02:26
when u build the html code it will open the website you made in google chrome
so u can check it out
Frank McCroy
@fmccroy
Jul 10 2017 02:30
hmm.. I have browser-sync to do that, although I haven’t tried it since I installed it. Once I open the html in my browser it will show changes as I save in Sublime,
arsovskidario
@arsovskidario
Jul 10 2017 02:31
send me a screenshot
Frank McCroy
@fmccroy
Jul 10 2017 02:35
I can’t really show it working at the moment, I’m not sure how to use it yet myself, but was told to install it for a Coursera course I’m taking. Here’s the link to it: https://www.browsersync.io/
Frank McCroy
@fmccroy
Jul 10 2017 02:42
It figures.. trying to test out browsersync now and it isn’t working right for me.
Frank McCroy
@fmccroy
Jul 10 2017 02:47
I have it working now, but it takes more steps to make browser-sync work. I had to start it from the command line first. Your way seems better if it would work right @arsovskidario.
Joel Y.
@zapcannon99
Jul 10 2017 02:58

I might be the only one, but is anybody having trouble loading twitch when clicking a link that brings you to the streamer's homepage.

For example, clicking on FreeCodeCamp on the example will not fully load their home twitch page.

Works on Safari, but not on Mozilla or Chrome
i can't get my head around this problem
arsovskidario
@arsovskidario
Jul 10 2017 03:07
@fmccroy Can you tell me the steps for browser sync I will install it now
mauriciodeleonc
@mauriciodeleonc
Jul 10 2017 03:19
function repeatStringNumTimes(str, num) {
  if (num > 0) {
    for (var i = 0; i < num; i++) {
      str += str;
    }
  } else {
    str = "";
  }
  return str;
}

repeatStringNumTimes("abc",3);
majinyu
@majinyu888
Jul 10 2017 03:19
Check for Palindromes 这道题怎么写正则表达式
mauriciodeleonc
@mauriciodeleonc
Jul 10 2017 03:21

function palindrome(str) {
  var nonAlpha = str.toLowerCase().replace(/[\W_]+/g,"");
  var backwards = nonAlpha.split("").reverse();
  backwards = backwards.join("");
  if (nonAlpha == backwards) {
    return true;
  } else {
    return false;
  }
}



palindrome("eye");
this is what i did
@majinyu888
arsovskidario
@arsovskidario
Jul 10 2017 03:25
@fmccroy i fixed the problem entered different cmd {
"cmd": ["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "$file"]
}
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:28
how to enter code in black background?
shivam gupta
@shivamg11000
Jul 10 2017 03:29
@KZinDaHouse use
body{
    color: white;
}
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:29
body {
I mean how to enter formatted code like yours
shivam gupta
@shivamg11000
Jul 10 2017 03:31
@KZinDaHouse ```
then code
then ```
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:33
let repeatNum = "42 42 42";
let reRegex = /change/; // Change this line
let result = reRegex.test(repeatNum);
@shivamg11000 thanks
CamperBot
@camperbot
Jul 10 2017 03:33
kzindahouse sends brownie points to @shivamg11000 :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @shivamg11000 |http://www.freecodecamp.com/shivamg11000
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:35
let repeatNum = "42 42 42";
let reRegex = /(\w+)\s\1/; // Change this line
let result = reRegex.test(repeatNum);
can someone help with this?
shivam gupta
@shivamg11000
Jul 10 2017 03:35
let repeatNum = "42 42 42";
let reRegex = /\d\d\s\d\d\s\d\d/; // Change this line
let result = reRegex.test(repeatNum);
@KZinDaHouse
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:37
@shivamg11000 lol, didn't expect that
but yours didn't work either
Joel Y.
@zapcannon99
Jul 10 2017 03:37
@Shivam, the question asks to use capture groups
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:38
yup, capture groups
Moisés Man
@moigithub
Jul 10 2017 03:45
Use capture groups in reRegex to match numbers that are repeated only three times in a string, each separated by a space.
Manish Giri
@Manish-Giri
Jul 10 2017 03:46
@KZinDaHouse why're you using \w+?
SopheaS
@SopheaS
Jul 10 2017 03:46
hi guys! why do i get undifined when I try to console.log(logo[0]). Please help me........
var userAccount = ["freecodecamp", "ESL_SC2", "OgamingSC2", "cretetion", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
var logo = [];
var dName = [];
function getData(){
        for(var i = 0; i < userAccount.length; i++){

        // get account display name, logo and description from API
            $.getJSON('https://wind-bow.gomix.me/twitch-api/users/' + userAccount[i] + '?callback=?', function(data){
                fillterData(data);
            });
        // get account status whether it is online or offline
            $.getJSON('https://wind-bow.gomix.me/twitch-api/streams/freecodecamp?callback=?', function(s) {
                getSteam(s);

            });

        }

        // get logos and display name from API
        function fillterData(data){
            logo.push(data.logo);
            dName.push(data.display_name);
        }

        // get status from API
        function getSteam(s){
            if(s.stream === null){
                userStatus.push("Offline");
            }else{
                userStatus.push("Online");
            }
        }

        console.log(logo[0]);



    }
Thank you so much
Moisés Man
@moigithub
Jul 10 2017 03:46
The example below matches any word that occurs twice separated by a space:
let repeatStr = "regex regex";
let repeatRegex = /(\w+)\s\1/;
Manish Giri
@Manish-Giri
Jul 10 2017 03:50
oh well the right answer doesn't seem to work as well
possible bug
KZinDaHouse
@KZinDaHouse
Jul 10 2017 03:51
@Manish-Giri i changed to \d+, still don't work
Moisés Man
@moigithub
Jul 10 2017 03:53

Your regex should not match "42 42 42 42".

after added ^$ passed all tests

Manish Giri
@Manish-Giri
Jul 10 2017 03:54
Screenshot 2017-07-09 23.53.00.png
I guess you need some additional check for four occurrences of 42
Moisés Man
@moigithub
Jul 10 2017 03:57
made this https://codeteca.herokuapp.com/snippets
took 1 month + 1 week while learning graphql + redux form + react router 4 + server rendering and having a lot of headaches with webpack config
Manish Giri
@Manish-Giri
Jul 10 2017 03:59
:+1:
Joel Y.
@zapcannon99
Jul 10 2017 04:04

@Manish-Giri

I think for whatever reason, javascript regex doesn't have the exact same clockwork as say c# regex. I tried your solution in js fiddle and some other sandboxes, and they all match 4 42s instead of 3

it's really odd
Moisés Man
@moigithub
Jul 10 2017 04:07
:point_up: July 9, 2017 10:53 PM should serves as hint ??? @zapcannon99
google what those symbols means on regex
Manish Giri
@Manish-Giri
Jul 10 2017 04:08
even without adding the start and end positions
I don't see why it shouldn't pass
it works on regexr
Joel Y.
@zapcannon99
Jul 10 2017 04:09
@moigithub
I know what they mean, but manish's solution gives the correct answer, but for whatever reason fails in javascript
Manish Giri
@Manish-Giri
Jul 10 2017 04:10
^^
Moisés Man
@moigithub
Jul 10 2017 04:11
test return true for "42 "x4 .. and should be false
(/(\d+)\s\1\s\1/).test("42 42 42 42")
true
Manish Giri
@Manish-Giri
Jul 10 2017 04:12
we know that
what we're pondering is why it returns true
Ken Haduch
@khaduch
Jul 10 2017 04:13
@Manish-Giri - why don't you think it should return true? (And hello...)
Moisés Man
@moigithub
Jul 10 2017 04:14
cuz the pattern is contained on the string ?
Manish Giri
@Manish-Giri
Jul 10 2017 04:14
@khaduch :point_up: July 9, 2017 11:54 PM
Ken Haduch
@khaduch
Jul 10 2017 04:15
@Manish-Giri - so if it occurs more than twice, it should not match? Is that the idea?
Moisés Man
@moigithub
Jul 10 2017 04:16
"42 42 42" is on "42 42 42 42 42 42 42" //true
adding ^$ it check for exact content from start to end... no extra values at middle
Manish Giri
@Manish-Giri
Jul 10 2017 04:16
@khaduch you mean more than thrice?
Ken Haduch
@khaduch
Jul 10 2017 04:17
@Manish-Giri - no I saw something up there about matching twice... so should it be thrice?
pahosler
@pahosler
Jul 10 2017 04:17
let repeatNum = "42 42 42";
let arr = repeatNum.match(/\d+\s*/g)
console.log(arr)
it needs to match only 3 times, so more than thrice should not match
the screenshot I posted (on regexr) matches 3, but not 4
yet it won't work on FCC unless you indicate start and end pos with ^ and $
pahosler
@pahosler
Jul 10 2017 04:21
you you can use ? instead of *
Manish Giri
@Manish-Giri
Jul 10 2017 04:21
you need to use capture groups
Ken Haduch
@khaduch
Jul 10 2017 04:24
@Manish-Giri - I think that the only way you can restrict it for their tests is to use the ^ and $? it seems like that is what you would need to do, looking at the test cases. Unless you have a way to indicate that it should not match the group after the third repetition?
Manish Giri
@Manish-Giri
Jul 10 2017 04:30
@khaduch I'm not sure why it won't work on fcc without using ^ and $
if you specify a sequence of 42 on regexr, it matches 42 42 42 only, and if there are 2 or more such sequences, it gives you multiple matches
Screenshot 2017-07-10 00.30.19.png
like 2 matches of 42 42 42 instead of 1 match of 42 42 42 42...
KZinDaHouse
@KZinDaHouse
Jul 10 2017 04:32
thanks @moigithub @Manish-Giri
CamperBot
@camperbot
Jul 10 2017 04:32
kzindahouse sends brownie points to @moigithub and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3489 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 6222 | @manish-giri |http://www.freecodecamp.com/manish-giri
Joel Y.
@zapcannon99
Jul 10 2017 04:32

Yeah, that's what I want to know.

Also, I'm really tired, so I made a dumb mistake when trying it in JS, yeah, Manish's regex works in JS.

So, FCC's response checkers are a bit weird I guess?

KZinDaHouse
@KZinDaHouse
Jul 10 2017 04:33
yeah i tried @Manish-Giri solution in another sandbox, and it worked fine
fdemaa
@fdemaa
Jul 10 2017 04:33
So im trying to delete the class of my div, it work great when i use queryselectorall, but now with get element is not working any idea ?
var select = document.getElementsByClassName("change5");
console.log(select);
for ( var i = 0; select<[i].length;i++){
  select[i].classList.remove("change5");

}
Manish Giri
@Manish-Giri
Jul 10 2017 04:34
@fdemaa select<[i].length - this looks weird
shouldn't it be i < select.length?
Ken Haduch
@khaduch
Jul 10 2017 04:34
@Manish-Giri - if you have the expression /(\d+)\s\1\s\1/ (that's what you have, right?) there is nothing to restrict it from matching any string that has 3 or more occurrences of the same number followed by a space. So if you have 4, 5, 6, etc occurrences of the same number, it won't matter, because the expression will match the first three and return true because there is a match. If you use the beginning and ending of line specifiers, then you will not fulfill all of the matching conditions if you have more than three (or even a trailing space after the last number) and it will fail.
fdemaa
@fdemaa
Jul 10 2017 04:35
@Manish-Giri thank manish lol :smile:
CamperBot
@camperbot
Jul 10 2017 04:35
fdemaa sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6223 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Jul 10 2017 04:35
@khaduch - I'm looking at the list of regexp challenges, and they have something that I'm not that familiar with - the "Negative lookahead" - that might be something that you could use?
KZinDaHouse
@KZinDaHouse
Jul 10 2017 04:36
@khaduch thanks that's very helpful
CamperBot
@camperbot
Jul 10 2017 04:36
kzindahouse sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3087 | @khaduch |http://www.freecodecamp.com/khaduch
KZinDaHouse
@KZinDaHouse
Jul 10 2017 04:36
so ^$ is required
Ken Haduch
@khaduch
Jul 10 2017 04:37
@KZinDaHouse - the negative lookahead might help to fulfill the requirements - I have to try it because as I said I"m not too familiar with using that.
Joel Y.
@zapcannon99
Jul 10 2017 04:37
@khaduch
Thanks for clarification @khaduch @Manish-Giri @moigithub
CamperBot
@camperbot
Jul 10 2017 04:38
zapcannon99 sends brownie points to @khaduch and @manish-giri and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3490 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 3088 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 6224 | @manish-giri |http://www.freecodecamp.com/manish-giri
Joel Y.
@zapcannon99
Jul 10 2017 04:39
So I guess what happens if we have text before the pattern, the ^$ won't work right?
Manish Giri
@Manish-Giri
Jul 10 2017 04:41
cool, ty @khaduch
CamperBot
@camperbot
Jul 10 2017 04:41
manish-giri sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3089 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jul 10 2017 04:41
@zapcannon99 - that's correct - it would strictly limit it to a set of three numeric values with a single space between each one. (And the negative lookahead doesn't seem to work, at least I cannot get it to work...)
Joel Y.
@zapcannon99
Jul 10 2017 04:47
@khaduch Good to know my brain remembers basic regex. Thanks.
CamperBot
@camperbot
Jul 10 2017 04:47
zapcannon99 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: zapcannon99 already gave khaduch points
Ken Haduch
@khaduch
Jul 10 2017 04:49
@zapcannon99 @Manish-Giri - these would be interesting lessons to go through - I need to shake the rust out of my brain on regexp... and I have to do it when I'm awake! :) Checking out now - thanks for twisting my brain in a knot... :)
CamperBot
@camperbot
Jul 10 2017 04:49
khaduch sends brownie points to @zapcannon99 and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6225 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 296 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
jorlee92
@jorlee92
Jul 10 2017 05:15
Hey I am working on the Show the Local weather project and I am having an issue with the Javascript being blocked. My code is here https://codepen.io/jorlee92/pen/JJaXme?editors=1010
I end up with an access-control-allow-origin error, and from googling it seems I need to do something with JsonP or CORS, I just want to be sure that this is actually something I need to do, or am I missing something simple
schizo99
@shashank1999coder
Jul 10 2017 05:25

// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var myTotal = 0;
for (var i = 0; i < myArr.length; i++) {
myTotal += myArr[i];
}its not working plz help guys

plz help guys
Alan Alickovic
@alan2207
Jul 10 2017 05:28
you probably need to return ourTotal @shashank1999coder
that is why you are not passing the challenge
you need to return the sum
Ogundele Olumide
@Lumexralph
Jul 10 2017 05:29
@shashank1999coder what's the instruction from FCC ?
@alan2207 return used out of the function or alone will return an illegal syntax error
Alan Alickovic
@alan2207
Jul 10 2017 05:31
@Lumexralph i guessed this code is inside a function, if not, i made a mistake
Ogundele Olumide
@Lumexralph
Jul 10 2017 05:32
@alan2207 maybe, that's why I asked for the instructions to helps us be clear of what's to be met
shivam gupta
@shivamg11000
Jul 10 2017 05:32
can anyone tell me the way to remove a element at a given index in array with the least code
Alan Alickovic
@alan2207
Jul 10 2017 05:33
@Lumexralph i agree with you, it can be confusing for someone if not explained well, will do that next time :smile:
@shivamg11000 you can use splice method
Adam Bohannon
@abohannon
Jul 10 2017 05:34
shivam gupta
@shivamg11000
Jul 10 2017 05:34
@alan2207 I know
Adam Bohannon
@abohannon
Jul 10 2017 05:34
@shivamg11000 do you have an example we can look at?
shivam gupta
@shivamg11000
Jul 10 2017 05:36
@abohannon @alan2207 ty
CamperBot
@camperbot
Jul 10 2017 05:36
shivamg11000 sends brownie points to @abohannon and @alan2207 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @abohannon |http://www.freecodecamp.com/abohannon
:cookie: 486 | @alan2207 |http://www.freecodecamp.com/alan2207
shivam gupta
@shivamg11000
Jul 10 2017 05:36
I have arrays of todos
Adam Bohannon
@abohannon
Jul 10 2017 05:37
@shivamg11000 should be straightforward to splice. If you want to paste your code I can take a deeper look.
shivam gupta
@shivamg11000
Jul 10 2017 05:37
@abohannon Its in my local machine
making a todo list in react
schizo99
@shashank1999coder
Jul 10 2017 05:38
total should be declared and initialized to 0
total should equal 20
You should use a for loop to iterate through myArr
Do not set total to 20 directly @Lumexralph
@alan2207 not working
Alan Alickovic
@alan2207
Jul 10 2017 05:39
@shashank1999coder is it inside a function?
Pieter Stokkink
@forkerino
Jul 10 2017 05:39
@shivamg11000 If you want to keep it pure and don't want to change the existing array, you should use .filter
Alan Alickovic
@alan2207
Jul 10 2017 05:39
can you give the link of the challenge?
Pieter Stokkink
@forkerino
Jul 10 2017 05:40
@shashank1999coder the variable should be total , not myTotal
Adam Bohannon
@abohannon
Jul 10 2017 05:42
@shivamg11000 ah. I'm not familiar with react yet, but splice would work like this:
var myList = ['todo1', 'todo2', 'todo3', 'todo4', 'todo5'];
var removed = myList.splice(3, 1);

// removed is ["todo4"]
// myList is ["todo1", "todo2", "todo3", "todo5"]
Ogundele Olumide
@Lumexralph
Jul 10 2017 05:57
@shashank1999coder it should be total not myTotal
@forkerino and he's here :wave:
schizo99
@shashank1999coder
Jul 10 2017 05:57
@forkerino thank you
CamperBot
@camperbot
Jul 10 2017 05:57
shashank1999coder sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2817 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jul 10 2017 06:01
@Lumexralph :wave:
JustCodeItBen
@JustCodeItBen
Jul 10 2017 06:22
I'm having trouble passing the Basic JavaScript: Profile Lookup challenge...here is my code:
function lookUpProfile(name, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (name === contacts[i].firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }
  }
// Only change code above this line
}
Ogundele Olumide
@Lumexralph
Jul 10 2017 06:23
@forkerino how're you?
@JustCodeItBen return No such contact outside the loop. after it's done
Pieter Stokkink
@forkerino
Jul 10 2017 06:25
@Lumexralph I'm ok. Had a very busy couple of days and didn't really have a lot of rest in the weekend, so this morning I am a bit tired. But this week will be more quiet.
And you?
Ogundele Olumide
@Lumexralph
Jul 10 2017 06:29
@forkerino same here too, only had Sunday to chill, going to work now....be good bro :wave:
Pieter Stokkink
@forkerino
Jul 10 2017 06:31
@Lumexralph You too! I'm on my way to work as well.
JustCodeItBen
@JustCodeItBen
Jul 10 2017 06:31
@Lumexralph Why is is the return statement outside of the for-loop? If the first if statement evaluated to false, then the else clause would be executed. With the else clause executed, then it would return "No such contact". That is the way I think of it.
Pieter Stokkink
@forkerino
Jul 10 2017 06:31
@JustCodeItBen What happens if the first contact doesn't match the name?
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 06:38
@JustCodeItBen You're returning too early. Just move your return "No such contact"; outside of the loop
JustCodeItBen
@JustCodeItBen
Jul 10 2017 06:45
I don't understand. What do you mean by "returning too early"?
Valdovas1
@Valdovas1
Jul 10 2017 06:50
Hello guys !

function destroyer(arr) {
  // Remove all the values
  var filtered = arguments[0].filter(arguments[1], arguments[2]);
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Why this is not working ?
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 06:51
@Valdovas1 becuase .filter expects function as first argument and you're passing in number
Valdovas1
@Valdovas1
Jul 10 2017 06:51
@SweetCodingInc Could you elaborate on this please ?
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 06:52
it should be something like
arguments[0].filter( function(el){
  // your filtering logic here
})
Valdovas1
@Valdovas1
Jul 10 2017 06:53
var filtered = (arguments[1], arguments[2])
?
aftewrwards ?
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 06:55
@Valdovas1 Consider these examples of .filter

var arr = [1,2,3,4,5,6,7,8,9,10];

var filtered = arr.filter( function(el){
  return el > 5;
});

console.log(filtered); // [6,7,8,9,10]
it will drop all elements that are not > 5
Valdovas1
@Valdovas1
Jul 10 2017 06:56
@SweetCodingInc Just a sec
Praveen Saraogi
@raviloop
Jul 10 2017 06:58
hello camphers i just now solved the "Caesars Cipher" Challenge, but i feel my code could be shortened and this can be done in little lines of code . if such is the case let me know .
below is my code:
function rot13(str) { 

  var code = [];
  var ans = [];

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

    code[i] = str.charCodeAt(i);

    if(code[i] != 32 && code[i] !=33 && code[i] !=63 && code[i] !=46)
    {
      code[i]+=13;
        if(code[i] > 90 )
          {
      var initial = 65;
      diff = code[i] - 90;
      code[i] = initial + (diff-1);
          }
    }
     ans.push(String.fromCharCode(code[i]));
  }

  return ans.join('');
}

// Change the inputs below to test
rot13("SERR CVMMN!");
Valdovas1
@Valdovas1
Jul 10 2017 06:59
@SweetCodingInc i get that arguments[0] is not a function :D
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 06:59
@Valdovas1 Show your updated code
Me_Is_Me
@NewProgrammerIsMe
Jul 10 2017 07:00
function palindrome(str)
Valdovas1
@Valdovas1
Jul 10 2017 07:01
var filtered = arguments[0].filter(arguments[1], arguments[2]); function destroyer(arr) {


  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
what I did I just moved the whole code out of a function and that might be a problem
Yet i do not understand how to move arguments[1] and arguments[2] inside the function so the function would get filtered
@SweetCodingInc
wonder
@wonder2991
Jul 10 2017 07:04
what if you don't know the number of arguments? that code won't work
Valdovas1
@Valdovas1
Jul 10 2017 07:05
@wonder2991 i have tested it and you are right.
Me_Is_Me
@NewProgrammerIsMe
Jul 10 2017 07:05

function palindrome(str) {
// 请把你的代码写在这里
if(str.replace(/[\w_]/g,'').toLowerCase()==str.replace(/[\w]/g,'').toLowerCase().split('').reverse().join(''))
return true;
else
return false;

}

palindrome("eye");

palindrome("not a palindrome") 应该返回 false.
I don't know how to correct it.
Valdovas1
@Valdovas1
Jul 10 2017 07:07
@wonder2991 Already read it and found out about arguments types that helped me to udnerstand their marking indeed
Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:07
@NewProgrammerIsMe you need another RegExp
@NewProgrammerIsMe for example: var newStr = str.replace(/[^0-9a-z]/gi, '');
Jan Shah
@JanShah
Jul 10 2017 07:08
var filtered = arguments[0].filter(arguments[1], arguments[2]); 
//your function hasn't started, there are no arguments yet
//filter function is not correct syntax
function destroyer(arr) {


  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@Valdovas1
Me_Is_Me
@NewProgrammerIsMe
Jul 10 2017 07:10
I can't tell the differences.
Valdovas1
@Valdovas1
Jul 10 2017 07:10
@CentropyIT if i insert the first line into the function it does not seem to work either
Jan Shah
@JanShah
Jul 10 2017 07:10
@Valdovas1 because your filter function is not correct
Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:12
@NewProgrammerIsMe then \W , don't \w
Valdovas1
@Valdovas1
Jul 10 2017 07:12
@CentropyIT Okey redoing
wonder
@wonder2991
Jul 10 2017 07:13
@NewProgrammerIsMe check your regex. it should be replacing non-alphaneumaric
Me_Is_Me
@NewProgrammerIsMe
Jul 10 2017 07:16
oh,got it.Thank you.
Valdovas1
@Valdovas1
Jul 10 2017 07:17

function destroyer(arr) {
  // Remove all the values
  return arr < filtered;
}
var filtered = arguments[0].filter(arguments[1], arguments[2]);
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
This one seems not to work either
Jan Shah
@JanShah
Jul 10 2017 07:19
function starts { and ends } there are no arguments outside this. arguments is still wrong and filter is still wrong. you need to rethink it
Valdovas1
@Valdovas1
Jul 10 2017 07:21
function destroyer(arr) {
  // Remove all the values
  return arr(arguments[0]).filter(arr(arguments[1]), arr(arguments[2]));
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Should arguments be like this ?
@CentropyIT
Jan Shah
@JanShah
Jul 10 2017 07:23
location is correct, filter function is still wrong
jorlee92
@jorlee92
Jul 10 2017 07:25
Hey, can anybody help me with requesting JSON data?
shivam gupta
@shivamg11000
Jul 10 2017 07:26
@jorlee92 yeah
wonder
@wonder2991
Jul 10 2017 07:26
filter requires a function. it will return the array elements that pass the test implemented by the provided function. @Valdovas1
jorlee92
@jorlee92
Jul 10 2017 07:27
@shivamg11000 Thanks, for some reason I keep getting no access-control-allow-origin header is present
CamperBot
@camperbot
Jul 10 2017 07:27
jorlee92 sends brownie points to @shivamg11000 :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @shivamg11000 |http://www.freecodecamp.com/shivamg11000
shivam gupta
@shivamg11000
Jul 10 2017 07:27
@jorlee92 whats the url you use to fetch data
Valdovas1
@Valdovas1
Jul 10 2017 07:29
@wonder2991 On it
wonder
@wonder2991
Jul 10 2017 07:29
:+1:
jorlee92
@jorlee92
Jul 10 2017 07:29
@shivamg11000 I just posted my entire pen, basically both APIs I used have the same issue
shivam gupta
@shivamg11000
Jul 10 2017 07:30
@jorlee92 Use dark sky api , open weather will not work
on codepen
and use ?callback=? at the end of the url
jorlee92
@jorlee92
Jul 10 2017 07:31
@shivamg11000 And that did it!
How did you know to do that? I couldnt find anything mentioning that
This took hours
shivam gupta
@shivamg11000
Jul 10 2017 07:32
@jorlee92
due to something called 'same-origin policy'
you cannot fetch data from different domains
directly
Jan Shah
@JanShah
Jul 10 2017 07:33
@jorlee92 developer tools in chrome give you a lot of into
Valdovas1
@Valdovas1
Jul 10 2017 07:33
var filtered = (function destroyer(arr) {
  // Remove all the values
  return arr(arguments[0]).filter(arr(arguments[1]), arr(arguments[2]));
});

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
?
shivam gupta
@shivamg11000
Jul 10 2017 07:33
@jorlee92 so here by adding callback at the end of the url , its requests the data from the site in jsonp which bypasses the same-origin policy
jorlee92
@jorlee92
Jul 10 2017 07:34
@shivamg11000 Alright, cool. I 100% need to learn more about this, it took me too long to figure this out
I probably should have asked for help earlier as well, but eh
wonder
@wonder2991
Jul 10 2017 07:38
@Valdovas1 not sure what you're trying to do there.
Valdovas1
@Valdovas1
Jul 10 2017 07:39
@wonder2991 trying to filter argumenta 1 an 2 from arr at the bottom
schizo99
@shashank1999coder
Jul 10 2017 07:39

//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
var answer = "No such contact";
contacts.some(function(arg) {
if (arg.firstName === firstName && arg.hasOwnProperty(prop) === true) {
answer = arg[prop];

}
else if (arg.hasOwnProperty === false) {
answer = "No such property";
}
});
return answer;

// Only change code above this line
}

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

plz help guys
wonder
@wonder2991
Jul 10 2017 07:40
function destroyer(arr) {
  return arr.filter(function(item){
    return ........;
  });
}
@Valdovas1
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
schizo99
@shashank1999coder
Jul 10 2017 07:41
plz help guys
wonder
@wonder2991
Jul 10 2017 07:41
'''
CamperBot
@camperbot
Jul 10 2017 07:41
:bulb: to format code use backticks! ``` more info
Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:42
@shashank1999coder you need two loop (one in one)
Valdovas1
@Valdovas1
Jul 10 2017 07:43
@wonder2991 why we use second function for filter ? as I do not quite sure i get it ?
Jan Shah
@JanShah
Jul 10 2017 07:45
@Valdovas1 have you used console before? developer tools in chrome?
if so, try this, to see what the filter function does
var array = [1,2,3,4,5,6]
array.filter(function(a){
  console.log(a)
})
Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:45
@shashank1999coder for example:
for (i = 0; i < arr.length; i++) {
if (arr[i].firstName == firstName) {
if (arr[i].hasOwnProperty(prop)) {
return arr[i][prop];
}
else {
return ....
wonder
@wonder2991
Jul 10 2017 07:46
Filter Syntax
var newArray = arr.filter(callback[, thisArg])

Parameters
callback:
Function is a predicate, to test each element of the array. Return true to keep the element, false otherwise, taking three arguments:
element:
The current element being processed in the array.
index:
The index of the current element being processed in the array.
array:
The array filter was called upon.
thisArg (Optional):
Optional. Value to use as this when executing callback.

Return value:
A new array with the elements that pass the test.
schizo99
@shashank1999coder
Jul 10 2017 07:49

//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 lookUp(firstName, prop) {

  for( var i = 0; i < arg.length; i++ ){
if( arg[i].firstName == firstName ) {
  if( arg[i].hasOwnProperty( prop ) ) {
    return arg[i].prop;
  } else {
    return "No such property";
  }
} else {
  return "No such contact";
} 

}

// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");
@vittorioVT still not working

ioakeimo
@ioakeimo
Jul 10 2017 07:51

Hello there.

I am trying to open a modal (using javascript) over an already existing modal which I create and deploy using html/bootstrap/jquery.
When I try to fire up the second modal I'm getting an error that my second modal is not defined.
Any ideas what I might be doing wrong?

JSFiddle

Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:52
@shashank1999coder this was example, you need contacts instead arg
@shashank1999coder you have array contacts
schizo99
@shashank1999coder
Jul 10 2017 07:55
still not working replaced contacts by arg
@vittorioVT
Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:55
@shashank1999coder show your code
schizo99
@shashank1999coder
Jul 10 2017 07:56

//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 lookUp(firstName, prop) {

  for( var i = 0; i < arg.length; i++ ){
if( arg[i].firstName == firstName ) {
  if( arg[i].hasOwnProperty( prop ) ) {
    return arg[i].prop;
  } else {
    return "No such property";
  }
} else {
  return "No such contact";
} 

}

// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");

Valdovas1
@Valdovas1
Jul 10 2017 07:56
@wonder2991 Stil does not work
function destroyer(arr) {
  return arr.filter(function(item){
    return item(arguments[0]).filter(item(arguments[1]), item(arguments[2]));
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
function destroyer(arr) {
  var filtered = arr.filter(function(item){
    return item(arguments[0]).filter(item(arguments[1]), item(arguments[2]));
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
even with this does not pass
schizo99
@shashank1999coder
Jul 10 2017 07:57
i think there is technical problem i will try refreshing page
Viktor Tiutiun
@vittorioVT
Jul 10 2017 07:57
@shashank1999coder you need contacts instead arg
schizo99
@shashank1999coder
Jul 10 2017 07:58
there is technical problem wait a sec.

//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 lookUp(firstName, prop) {

  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 property";
  }
} else {
  return "No such contact";
} 

}

// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");

not working still
@vittorioVT
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:00
@shashank1999coder return contacts[i][prop];
schizo99
@shashank1999coder
Jul 10 2017 08:00
still not
wonder
@wonder2991
Jul 10 2017 08:01
@Valdovas1 filter(item(arguments[1]), item(arguments[2])) filter doesnt work like this.
Read the docs and take your time. it won't help if i just give you the answer.
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:01
@shashank1999coder you have else one mistake
Thayyeb salim
@Thayyebsalim
Jul 10 2017 08:01
thanks @abohannon @forkerino
CamperBot
@camperbot
Jul 10 2017 08:01
thayyebsalim sends brownie points to @abohannon and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @abohannon |http://www.freecodecamp.com/abohannon
:star2: 2818 | @forkerino |http://www.freecodecamp.com/forkerino
Valdovas1
@Valdovas1
Jul 10 2017 08:02
@wonder2991 thank you
CamperBot
@camperbot
Jul 10 2017 08:02
valdovas1 sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 392 | @wonder2991 |http://www.freecodecamp.com/wonder2991
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:02
@shashank1999coder you missing }
@shashank1999coder return contacts[contact][prop];
}
else {
return "No such property";
}
}
}
return "No such contact";
schizo99
@shashank1999coder
Jul 10 2017 08:03
nope thats not a mistake
when i add system showing unexpected token
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:04
@shashank1999coder this code for me works
Coy Sanders
@coymeetsworld
Jul 10 2017 08:04
@shashank1999coder the problem is you are saying no such contact exists in the wrong place
you can only say a contact doesn't exist if you go through the entire contacts array and do not find the person you're looking for
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:06
@shashank1999coder after return "No such contact"; else one }
schizo99
@shashank1999coder
Jul 10 2017 08:07

//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 lookUp(firstName, prop) {

  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";
}

    else {
    return "No such property";
  }

}

// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");

Coy Sanders
@coymeetsworld
Jul 10 2017 08:08
no you took a step backwards
if you find a contact and the property doesn't exist, you don't return "No such contact", you found the contact so that isn't true
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:09
@shashank1999coder after "return contacts[contact][prop];"
must be one "}" before "else"
schizo99
@shashank1999coder
Jul 10 2017 08:10
@vittorioVT but when i add one its showing unexpected token
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:11
@shashank1999coder look at your function, what and where you are closing
schizo99
@shashank1999coder
Jul 10 2017 08:12
} is not a problem
Rawikitua Isherwood
@rawiki
Jul 10 2017 08:13
Is it just me or is the No Repeats Please challenge way harder than any of the other problems?
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:14
@shashank1999coder first you close the first if, then go else between should be only one }
schizo99
@shashank1999coder
Jul 10 2017 08:15
//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 lookUp(firstName, prop) {
// Only change code below this line
var answer = "No such contact";
contacts.some(function(arg) {
if (arg.firstName === firstName && arg.hasOwnProperty(prop) === true) {
answer = arg[prop];
} else if (arg.hasOwnProperty(prop) === false) {
answer = "No such property";
}
});
return answer;
// Only change code above this line
}
// Change these values to test your function
lookUp("Kristian", "lastName");
treid some different
tried*
@vittorioVT @coymeetsworld
Coy Sanders
@coymeetsworld
Jul 10 2017 08:15
@rawiki they are advanced algorithms so they are supposed to be challenging, they are optional too. Can always revisit when you learn more
@shashank1999coder you keep going further backward and backward
where is your for loop?
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:16
@shashank1999coder why arg again you need contacts
Coy Sanders
@coymeetsworld
Jul 10 2017 08:16
you still need to iterate through the contacts array to find the contact
heroiczero
@heroiczero
Jul 10 2017 08:16
@rawiki Personally I try to figure out what it is trying to do first and solve the problems in blocks
Rawikitua Isherwood
@rawiki
Jul 10 2017 08:17
@coymeetsworld I finished all the other advanced algorithms without trouble. Been stuck on this for a while
schizo99
@shashank1999coder
Jul 10 2017 08:18
@vittorioVT @coymeetsworld my latest one is working but i cannot surpass the challenge why
Coy Sanders
@coymeetsworld
Jul 10 2017 08:19
where did you copy that code from?
probably should make your own answers
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:20
@shashank1999coder how it can work if your array is called contacts and you work with arg?
Coy Sanders
@coymeetsworld
Jul 10 2017 08:21
hes using a callback
Saikat-Sinha
@Saikat-Sinha
Jul 10 2017 08:27
Please help with my React Application http://juniordev.me/React-Commenting-System/ , whenever I comment it does not re render, please tell me how to re render this component .......... my code at https://github.com/Saikat-Sinha/React-Commenting-System
KinderPreet Singh
@kindercappy
Jul 10 2017 08:30
Need some advice.
Ive been able to do 5 advance algos by myself. The other 5 i took hints and peeked a bit at solutions did not copy them but just tried to look at the logic. Is that wrong?
Viktor Tiutiun
@vittorioVT
Jul 10 2017 08:41
@kindercappy it's normal :smile:
KinderPreet Singh
@kindercappy
Jul 10 2017 08:42
@vittorioVT thanks :)
CamperBot
@camperbot
Jul 10 2017 08:42
kindercappy sends brownie points to @vittoriovt :sparkles: :thumbsup: :sparkles:
:cookie: 771 | @vittoriovt |http://www.freecodecamp.com/vittoriovt
ioakeimo
@ioakeimo
Jul 10 2017 09:09
Anyone can help with bootstrap modals? I can't present my modal using JS...
Bomee
@Bomulacious
Jul 10 2017 09:13
im so stuck in this challenge and would appreciate any help. Not sure what function i need to write here.
Coy Sanders
@coymeetsworld
Jul 10 2017 09:13
@Bomulacious they give you some hints
the filter function would work well for that problem
Bomee
@Bomulacious
Jul 10 2017 09:14
@coymeetsworld yea i think i read that like 100 times
Coy Sanders
@coymeetsworld
Jul 10 2017 09:15
both the links they provide would help, the Arguments link can show you how to separate the arguments (i.e. the array, and the numbers they want you to remove from the array)
and then the filter function is how you would accomplish removing each item from the array
Dipal Gudhka
@dipalgudhka
Jul 10 2017 09:24
// noprotect
function smallestCommons(arr) {

  var number, product;

  if (arr[0] > arr[1]) {
    number = arr[0];
    arr[0] = arr[1];
    arr[1] = number;
  }

  number = arr[1] - arr[0];

  arr.splice(1, 1);

  for (var i = 1; i <= number; i++) {
    arr.push(arr[0] + i);
  }

  console.log(arr);

  var counter = 0;

  for (var j = 2; j > 0; j++) {

    product = arr[0] * j;
    console.log(product);


    for (var m = 0; m < arr.length; m++) {
      if (product % arr[m] === 0) {
        counter++;
      }
    }

    if (counter == arr.length) {
      return product;
    }
    else {
      counter = 0;
    }
  }

//   return arr;
}

smallestCommons([1,13]);
I managed to get outputs. But the algorithm is slow to process. Is there anything better?
mixa1901
@mixa1901
Jul 10 2017 09:25
hi dudes... "Sum All Odd Fibonacci Numbers" challenge...i managed to do fibonacci with odd and even numbers... help me to do it only with odd numbers, pls

function sumFibs(num) {
 var a = 0;
  var b = 1;
var z;
 for (var i=0; i < num; i++) {
   z = a + b;
   a=b;
   b=z;
 }

  return z;
}

sumFibs(5);
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:26
I don't remember how I did it without looking it up.
the second thing is how to tell if a number is even/odd is if it has a remainder when divided by 2.
Dipal Gudhka
@dipalgudhka
Jul 10 2017 09:27
@mixa1901 Try using filter
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:28
I just woke up, the first may b e wrong
I'm here because of the record collection. Mostly to feel warm and fuzzy because I did the phone validatinn in one line of code using a regular expression cuz I woke up at oh-dark thirty local and said,"y'know....." I looked at record collection and am trying to wrap my head around what is the desired behavior.
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:34
@dipalgudhka I didn't look at all your code but .... Euclid's LCM algorithm might help you: http://staff.www.ltu.se/~larserik/applmath/chap10en/part3.html you need a GCF function though
Dipal Gudhka
@dipalgudhka
Jul 10 2017 09:35
@baseballpoetess Thanks alot. Let me check that out.
CamperBot
@camperbot
Jul 10 2017 09:35
dipalgudhka sends brownie points to @baseballpoetess :sparkles: :thumbsup: :sparkles:
:cookie: 751 | @baseballpoetess |http://www.freecodecamp.com/baseballpoetess
Yogender
@yb1997
Jul 10 2017 09:38
https://codepen.io/ybisht1997/pen/gRdBBO?editors=0010
How do I reduce code size ? is there any other alternative ways to do the same thing with less lines of code
h1b12
@h1b12
Jul 10 2017 09:39
Hello i am stuck in freecodecamp i made a portfolio here.
https://codepen.io/h1b2/pen/awRKWy?editors=1000 . But the "Portfolio" box and the "Contact" box isn't divided.
And i dont find a way to center "contact title" and i need to align "twitter, github and facebook".
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:40
@yb1997 I think for what you're doing you may have to do it that way. This is so not my thing though.
@h1b12 okay, pick one thing to focus on, which first?
h1b12
@h1b12
Jul 10 2017 09:41
Dividing the box
boxes*
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:42
Okay, check to make sure every <div> has a matching </div> Codepen should help by highlighting the corresponding one if you put your cursor on one.
Yogender
@yb1997
Jul 10 2017 09:43
@h1b12 lol whenever I am trying to run your pen, chrome is giving me ran out of memory error
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:44
Thre is also a down-arrow at the top-right. If you click it, it opens a menu. One option is "Tidy HTML" That sometimes helps, too.
h1b12
@h1b12
Jul 10 2017 09:44
@baseballpoetess i will try thaks
thanks*
You mean "settings"
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:46
No, on the right
it looks like a down-pointing ^
h1b12
@h1b12
Jul 10 2017 09:47
Ah
You mean the arrow for minimizing and maximizing
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:48
I think in the line 50-51 area you need a </div> but I could be misreading.
Sanket Chaudhari
@sanket143
Jul 10 2017 09:48
open your console when you hit this link
to see the problem with darksky (don't forget to click the button)
https://codepen.io/Sanket143/pen/YQJLLx?editors=0010
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:49
@sanket143 you need ?callback=? in your call to the API.
Delete one of those.
you don't need to spam us.
Victor Popescu
@VicPopescu
Jul 10 2017 09:50
@sanket143 why u spam all rooms?
Sanket Chaudhari
@sanket143
Jul 10 2017 09:51
sorry
my internet is slow
I was unable to see whether the message is sent or not
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:52
@h1b12 did you try a </div> on line 51?
Yogender
@yb1997
Jul 10 2017 09:52
@h1b12 you can try btn-group class to group all three buttons
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:53
tidy HTML and try that.
We're working on splitting the contiguous blackness
(finding where the missing </div> is will probably help the buttons)
wonder
@wonder2991
Jul 10 2017 09:57
@h1b12 add three </div> after line 61
h1b12
@h1b12
Jul 10 2017 09:58
Yeah i did it for line 51 @baseballpoetess
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 09:59
Okay, if that's not right then maybe what @wonder2991 says .....
Pedro Almeida
@pmqa
Jul 10 2017 09:59

hey guys, I have this object:
const categories = vidData.data.map((vid) => { return { id: vid.id, title: () => { return 'something'; } } });

I would like to have the title property be the string that the function returns, the string ‘something’. Instead the property is the function itself. Do you know what I mean? Is this possible?

J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:00
you can return a function @pmqa I'm not sure what you're trying to do though.
h1b12
@h1b12
Jul 10 2017 10:00
@wonder2991 i added 3 </div>
wonder
@wonder2991
Jul 10 2017 10:00
did it work?
Pedro Almeida
@pmqa
Jul 10 2017 10:01
I want to return a string not the function that generates the string but I’m not sure how
h1b12
@h1b12
Jul 10 2017 10:01
Yeah but the contact box disaspear
disapeared*
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:02
@pmqa I'm not good with arrows yet.
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:02
@pmqa Just do an IIFE forthat.
Like that
const categories = vidData.data.map(vid => {
  return {
    id: vid.id,
    title: (() => {
      return "something";
    })()
  };
});
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:04
I still see na arrow.
h1b12
@h1b12
Jul 10 2017 10:04
@wonder2991 yeah?
Yogender
@yb1997
Jul 10 2017 10:04
@pmqa try (vid)=>vid.title; if you only want to return string
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:04
I'm not trying to be a jerk-- I'm only a n00b at js but lots of years of coding in other languages.
Pedro Almeida
@pmqa
Jul 10 2017 10:04
That’s it, Sweet Coding, thanks again :)
wonder
@wonder2991
Jul 10 2017 10:05
@h1b12 how do you want it displayed?
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:06
:) Okay, can you explain what that does? I want to learn.
h1b12
@h1b12
Jul 10 2017 10:06
@wonder2991 Do you see the translucent box in "portfolio" and "Idriss K"
?
wonder
@wonder2991
Jul 10 2017 10:06
yeah
ok
h1b12
@h1b12
Jul 10 2017 10:07
I want to do the same thing for contact
Yogender
@yb1997
Jul 10 2017 10:07
@pmqa did that worked?
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:08
(I am watching a video on IIFEs..... that is so cool to see it ... IRL but I'm not sure I totally get the arrow part)
wonder
@wonder2991
Jul 10 2017 10:11
@h1b12 you should probably get your markup validated. it's a mess.
https://validator.w3.org/
Yogender
@yb1997
Jul 10 2017 10:11
@baseballpoetess function(data) { return data; } is same as (data)=>data;
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:11
even data => data
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:11
ah!
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:12
if you have one parameter to a function, you don't need brackets
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:12
which data is which though?
Yogender
@yb1997
Jul 10 2017 10:12
oh yea right
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:12
same data that is being passed to the function
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:12
oh
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:12
it doesn't make sense in this example though
Yogender
@yb1997
Jul 10 2017 10:13
if you only want to return something and nothing else then this method is quite clean
h1b12
@h1b12
Jul 10 2017 10:13
@wonder2991 ok
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:13
so the arrow means param => output ?
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:13
Consider this example
const obj = {
  id:1,
  name: 'Peter Griffin'
}

const getName = data => data.name;

console.log(getName(obj)); // Peter Griffin
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:14
there has to be a lesson on it at some point.
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:14

const getName = data => data.name;
Exactly same as

const getName = data => {
  return data.name;
}
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:14
Probably after algorithms.
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:15
@baseballpoetess lesson on this in FCC curriculum?
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:15
yeah.
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:15
I don't think so
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:15
dayum
Pedro Almeida
@pmqa
Jul 10 2017 10:15
@yb1997 it did
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:15
It's es6 syntax.. There is nothing ES6 can do that you can not with ES5
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:15
okay, maybe a video? What is my search term.
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:15
ES6
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:15
kk :)
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:15
Fat Arrow Functions
or Arrow Functions
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:16
thanks @SweetCodingInc
CamperBot
@camperbot
Jul 10 2017 10:16
baseballpoetess sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 103 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:16
:+1:
h1b12
@h1b12
Jul 10 2017 10:16
@wonder2991 Man i am not english fluent so i dont understand which part i have to replace. Do you have an example?
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:16
It might be covered later in the Weird Javascript series -- I'm on IIFEs now.
Yogender
@yb1997
Jul 10 2017 10:16
for learning JS in depth, I recommend JS the wierd parts by tony alicia on udemy
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:17
yeah, I'm on IIFEs in that series.
I think it's /alicia/alicea/
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:18
YDKJS doesn't have ES6 syntax
but in any case, as long as you understand pure JS well, there is nothing magical about ES6
sure, arrows look cool and stuff.. but yeah...
Yogender
@yb1997
Jul 10 2017 10:19
yea
wonder
@wonder2991
Jul 10 2017 10:19
@h1b12 i added <div class='spacer'></div> above your contact and change the 1st div's class to block <div class='block'>
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:19
I beg to differ. I have to be able to read code. 90% of any job is reading what is already there.
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:19
90% of industry doesn't understand ES6 :D
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:19
oh, good. :)
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:19
let alone writing code in ES6 or TypeScript
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:20
kk
Yogender
@yb1997
Jul 10 2017 10:20
learning pure JS can help to move on from one framework or library to another very easily
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:20
We recently migrated our entire codebase from Angular 1.6 to 4, and our lead architect had no clue what typescript was...
h1b12
@h1b12
Jul 10 2017 10:20
ok i 'll do it in mine too
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:21
I know what it's like in other languages and it only takes one.
Yogender
@yb1997
Jul 10 2017 10:21
lol
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:21
And this is the case in Silicon Valley! :D
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:21
I feel encouraged.
Yogender
@yb1997
Jul 10 2017 10:21
@SweetCodingInc how did u manged to migrate it without breaking any functionalities ?
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:21
Java 8 brought in Lambda expression and everyone went apeshit
no one understood what was going on :D
Pedro Almeida
@pmqa
Jul 10 2017 10:23
Incredible but true @SweetCodingInc , on the other hand sometimes I feel that you can do pretty much everything without knowing the core algorithm manipulation functions of a language as long as you know where everything fits in the broad picture
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:23
@yb1997 : Thankfully for us the code was written in component fashion from the get go.. So there were couple minor component installation points that needed refactoring. Rest was just ported using ngUpgrade
now were are slowly migrating each component to typescript
h1b12
@h1b12
Jul 10 2017 10:23
@wonder2991 great thanks mate.
CamperBot
@camperbot
Jul 10 2017 10:23
h1b12 sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @wonder2991 |http://www.freecodecamp.com/wonder2991
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:23
but the older ES6 works just well
Yogender
@yb1997
Jul 10 2017 10:23
nice
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:24
@pmqa :+1:
wonder
@wonder2991
Jul 10 2017 10:24
you're welcome @h1b12 :thumbsup:
h1b12
@h1b12
Jul 10 2017 10:28
@wonder2991 Dude i checked my code in another website it tell me there is 151 errors
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:29
yeah
probably becuase you're using bs and it didn't have access to that .
so it's barfing on all the bs calls/classes.
wonder
@wonder2991
Jul 10 2017 10:31
where did you check it? @h1b12
h1b12
@h1b12
Jul 10 2017 10:31
What is a bs class?
wonder
@wonder2991
Jul 10 2017 10:31
probably bootstrap
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:31
bullshit class
h1b12
@h1b12
Jul 10 2017 10:31
ok
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 10:31
jk
bootstrap
It's in french
wonder
@wonder2991
Jul 10 2017 10:32
you are using the codepen link
h1b12
@h1b12
Jul 10 2017 10:33
yeah
wonder
@wonder2991
Jul 10 2017 10:33
just copy the code and check it
h1b12
@h1b12
Jul 10 2017 10:35
It found 2 mistake for the html code
wonder
@wonder2991
Jul 10 2017 10:36
that's better
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 10:36
yes.
h1b12
@h1b12
Jul 10 2017 10:37
Which most of my code need to be cleaned up.
mean*
Kriis1
@Kriis1
Jul 10 2017 10:38

hi guys! var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
singleVal = array.reduce (function(previousVal, currentVal) {
return peviousVal + currentVal;
});

who can help me
i am stuck
wonder
@wonder2991
Jul 10 2017 10:39
check spelling
peviousVal
Kriis1
@Kriis1
Jul 10 2017 10:40
@wonder2991 thank you!! but why pevious
CamperBot
@camperbot
Jul 10 2017 10:40
kriis1 sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 394 | @wonder2991 |http://www.freecodecamp.com/wonder2991
wonder
@wonder2991
Jul 10 2017 10:41
no it should be previousVal. it should be what you declared in the function's argument @Kriis1
h1b12
@h1b12
Jul 10 2017 10:57
I am stuck in this course
Sans titre.png
can you help me?
Robert Uivarosi
@URobert
Jul 10 2017 11:00
@h1b12 You didn't use ' ' or " " pairs
for your string
Long Nguyen
@longnt80
Jul 10 2017 11:00
@h1b12 I am a is a string you need quotes
"I am a"
Robert Uivarosi
@URobert
Jul 10 2017 11:00
'''
CamperBot
@camperbot
Jul 10 2017 11:00
:bulb: to format code use backticks! ``` more info
wonder
@wonder2991
Jul 10 2017 11:00
your string should be between quotes
Long Nguyen
@longnt80
Jul 10 2017 11:01
@h1b12 you should hover on the red circle on the left of that line, it already shows the why
Robert Uivarosi
@URobert
Jul 10 2017 11:01
"I am a string" vs I am a string. 
First one works, the other doesn't. The quotes are used to identify a string data type
Rakesh Goswami
@theunmarwadi
Jul 10 2017 11:12
Can anybody suggest me good books for JavaScript please!
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 11:13
The classic is "You Don't know JS" but i'm afraid I don't have the link.
wonder
@wonder2991
Jul 10 2017 11:13
ydnjs
Long Nguyen
@longnt80
Jul 10 2017 11:13
@theunmarwadi You Don't Know JS
wonder
@wonder2991
Jul 10 2017 11:13
wah
Long Nguyen
@longnt80
Jul 10 2017 11:13
holy
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 11:13
Rakesh Goswami
@theunmarwadi
Jul 10 2017 11:13
Other than you don't know js??
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 11:14
I'm watching videos.
Understanding weird parts is a 12 hour long series
Long Nguyen
@longnt80
Jul 10 2017 11:15
@theunmarwadi Eloquent Javascript
Javascript: The good Parts
@theunmarwadi and You Don't Know JS is free to read online
wonder
@wonder2991
Jul 10 2017 11:16
i'm going through eloquent js
Rakesh Goswami
@theunmarwadi
Jul 10 2017 11:20
@longnt80 Thanks a lot bro
CamperBot
@camperbot
Jul 10 2017 11:20
theunmarwadi sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 434 | @longnt80 |http://www.freecodecamp.com/longnt80
Innocent Tauzeni
@Telthem89
Jul 10 2017 11:24
hello team
Ogundele Olumide
@Lumexralph
Jul 10 2017 11:24
Hi
Frostbites
@Frostbites
Jul 10 2017 11:38
Hey folks
How is everyone?
I am stuck
and I don't know why it's not working
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 11:38
Hi Stuck!
Frostbites
@Frostbites
Jul 10 2017 11:38

function slasher(arr, howMany) {

  var newArr = [];
  i = 0;

  if (arr.length >= howMany) {
    while (i < howMany) { 
      newArr = newArr.push(arr.slice(0, howMany));
      i++;

    }
    return newArr;
  }
  else {
    return [];
  }

}


slasher([1, 2, 3], 2);
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 11:39
@Frostbites Get rid of newArr = from newArr = newArr.push(arr.slice(0, howMany));
Frostbites
@Frostbites
Jul 10 2017 11:39
I am supposed to take out values from the given array and put a specific number of values in a new array returning it
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 11:39
.push returns length of the array after you push the element
it should just be newArr.push(arr.slice(0, howMany));
Frostbites
@Frostbites
Jul 10 2017 11:40
Okay
now it returns 2 arrays with indexes starting from 0
Thanks @SweetCodingInc
CamperBot
@camperbot
Jul 10 2017 11:44
frostbites sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 105 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
Frostbites
@Frostbites
Jul 10 2017 11:44
what next?
I can't understand where I got it wrong
Innocent Tauzeni
@Telthem89
Jul 10 2017 11:46
hey team i want to create Twitch.tv JSON API.....how can i do that
Frostbites
@Frostbites
Jul 10 2017 11:49

function slasher(arr, howMany) {

  var newArr = [];  

  if (arr.length > howMany) {
      newArr.push(arr.splice(howMany));
      return newArr;
    }
  else {
    return [];
  }

}



slasher([1, 2, 3], 0);
This works
Markus Kiili
@Masd925
Jul 10 2017 11:49
@Frostbites You could do it with just:
Frostbites
@Frostbites
Jul 10 2017 11:49
but it shows [[1,2,3]] instead of [1,2,3]
Markus Kiili
@Masd925
Jul 10 2017 11:49
function slasher(arr, howMany) {
  return arr.slice(howMany);
}
Splice works too.
Frostbites
@Frostbites
Jul 10 2017 11:50
@Masd925 Thanks dude
CamperBot
@camperbot
Jul 10 2017 11:50
frostbites sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4289 | @masd925 |http://www.freecodecamp.com/masd925
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 11:52
function slasher(arr, howMany) {

  var newArr = [];
  i = 0;

  if (arr.length >= howMany) {
    while (i < arr.length) { 
      newArr.push(arr.slice(i, i+howMany));
      i+=howMany;

    }
    return newArr;
  }
  else {
    return [];
  }

}


slasher([1, 2, 3], 2);
Innocent Tauzeni
@Telthem89
Jul 10 2017 11:58
help
Stephen James
@sjames1958gm
Jul 10 2017 12:00
@Telthem89 What's up?
Innocent Tauzeni
@Telthem89
Jul 10 2017 12:19
@sjames1958gm am cool bro hw a u doing
@sjames1958gm to get online streamer .....twitch.tv can what cn i do help
Thomas
@sjurs1
Jul 10 2017 12:21

Hello! I'm cleaning up my Wikipedia viewer because to be honest it was pretty lacking. I've gotten hold of the json I want, but I'm not quite sure how I should display it all.

function getArticles(searchWord) {
  $.ajax({
    type: "GET",
    url: "https://en.wikipedia.org/w/api.php?format=json&origin=*&action=query&generator=search&prop=extracts&exlimit=10&exintro=true&explaintext=true&gsrsearch=" +
      searchWord,
    success: function(data) {
      let pageids = Object.keys(data.query.pages);
      console.log(data.query.pages[pageids[0]].extract);
      $("#newArticle").addClass("newArticle animated fadeIn");
      $("#newArticle").text(data.query.pages[pageids[0]].extract)
    }
  });
};

The last two lines in my code there displays the extract of the first wikipedia hit, but I have ten of them. There should be a better way to display all of them than typing each and every case out and have a corresponding div element to use jQuery on. Anyone have any thoughts or methods they can link me?

Stephen James
@sjames1958gm
Jul 10 2017 12:22
@Telthem89 When you fetch the stream API if the stream object is not null then the streamer is online
@sjurs1 Loop over the pageids array. where you have pageids[0] you put pageids[i]
J-Mag Guthrie
@baseballpoetess
Jul 10 2017 12:23
@sjurs1 Yes. I used a loop.
Thomas
@sjurs1
Jul 10 2017 12:24
@sjames1958gm I thought about that, but can I just .text that to the same div element id? Or can I just add html formatting in the loop to make sure the different articles are seperated?
Stephen James
@sjames1958gm
Jul 10 2017 12:25
@sjurs1 You will want to append to a parent element.
Nick Janne
@njanne19
Jul 10 2017 12:25
Could anyone help me out in figuring out why my state is undefined in the component's methods below.
They're all in the same component, and the method is being passed to a child. See here: https://s.codepen.io/njanne19/debug/BZOJmq/PNAvYLgREBVr
For whatever reason, the birth() method inside the Game component cannot see its state. I don't understand why
Stephen James
@sjames1958gm
Jul 10 2017 12:27
@njanne19 Can you give the edit link so we can see the code?
@sjurs1 Create a new element to put the extract into to then append
@sjames1958gm
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 12:28
@sjurs1 Something like this
$ul = $('<ul/>');
for(let page in data.query.pages){
  let p = data.query.pages[page];
  let $li = $('<li/>', {
    text: p.extract,
    'class':'newArticle animated fadeIn'
  });
  $ul.append($li);
}
$("#newArticle").append($ul);
Stephen James
@sjames1958gm
Jul 10 2017 12:32
@njanne19 Did you try binding this before the for loop where you create Cells
Nick Janne
@njanne19
Jul 10 2017 12:33
@sjames1958gm ... how do you know this stuff
Stephen James
@sjames1958gm
Jul 10 2017 12:37
@njanne19 Well it all looked correct how you did the binding. Then I noticed that the binding was after the for loop.
A lot of this is just experience from making the same mistakes in the past.
Nick Janne
@njanne19
Jul 10 2017 12:38

@sjames1958gm Thanks, I think you've been my biggest hero on gitter. Do you see what I'm doing wrong here?

  birth(id) {
    let newState = this.state.lifeArray;
    newState[id] = 1;
    this.setState({ lifeArray: newState });
    console.log(this.state.lifeArray[0]);
  }

I'm trying to make an array of 1's and 0's in order to track the life of every cell but for some reason the state isn't updating

CamperBot
@camperbot
Jul 10 2017 12:38
njanne19 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8031 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 10 2017 12:39
@njanne19 I don't believe that setState will update the variable this.state immediately, but it should be set in the next render() call
h1b12
@h1b12
Jul 10 2017 12:40
Hi there
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:40
hey guys, I wanna ask sth about the method's syntax
anyone can help here ?
Nick Janne
@njanne19
Jul 10 2017 12:40
@sjames1958gm it doesn't appear to be updating in render either
@AhmedMJ send out some code we can all try and help
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:41
@njanne19 thank you
CamperBot
@camperbot
Jul 10 2017 12:41
ahmedmj sends brownie points to @njanne19 :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @njanne19 |http://www.freecodecamp.com/njanne19
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:41
the split method
when it's in use
it goes this way
str.split(" ", 5);
but in the documentation it's like this
str.split([separator[, limit]])
it's like the max separating length argument is an index of the separator..
is there any explanation for this ?
Nick Janne
@njanne19
Jul 10 2017 12:43
@AhmedMJ can you explain what your '5' is doing?
Like that's not 100% necessary to use .split
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:43
the limit of the separation
yeah i know it's optional
but the syntax example in the MDN documentation suggests it this way
Thomas
@sjurs1
Jul 10 2017 12:45
@sjames1958gm @SweetCodingInc Thanks guys! Clever
CamperBot
@camperbot
Jul 10 2017 12:45
sjurs1 sends brownie points to @sjames1958gm and @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 108 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
:star2: 8032 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Nick Janne
@njanne19
Jul 10 2017 12:45
@AhmedMJ Here's a better example of it
var str = "How are you doing today?";
var res = str.split(" ", 3);
How,are,you
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:45
yeah that's the way i use it and it works 100%
but the documentation suggests it this wa y
way*
str.split([separator[, limit]])
like if i wanted to substitute the arguments
it's gonna be this way
str.split([""[, 3]])
Nick Janne
@njanne19
Jul 10 2017 12:46
Right so I think the limit in that documentation page allows there to be a functional limit instead of a primitive limit
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:47
functional limit, primitive limit ?
what's the difference ?
and I don't know they mean :worried:
Saif Ur Rahman
@saifsmailbox98
Jul 10 2017 12:48
@AhmedMJ [, limit] this means that the limit is optional. But if you want to add the limit remove the [ ]s.
Nick Janne
@njanne19
Jul 10 2017 12:48
Sorry, so a functional limit would mean like potentially an external source is calculating a limit, as if it varies based on a function. (i.e. a function is calculating your limit) v.s. a primitive limit which is a defined value such as 3 or 4
Stephen James
@sjames1958gm
Jul 10 2017 12:48
@AhmedMJ the [] mean optional arguments, not that you need [] when passing the value
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:49
@njanne19 ahaaa,, that was beneficial , thank you man ^^
CamperBot
@camperbot
Jul 10 2017 12:49
ahmedmj sends brownie points to @njanne19 :sparkles: :thumbsup: :sparkles:
:warning: ahmedmj already gave njanne19 points
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:49
@saifsmailbox98 @sjames1958gm ahaa, that makes sense now =D
thank you guys ^^
CamperBot
@camperbot
Jul 10 2017 12:49
ahmedmj sends brownie points to @saifsmailbox98 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 745 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:star2: 8033 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ahmed Majdi
@AhmedMJ
Jul 10 2017 12:51
thank you guys ,, it's all clear now ^^
Thomas
@sjurs1
Jul 10 2017 12:53
@SweetCodingInc So in jQuery, as a general example, '<ul/>' is just short-hand for <ul></ul>?
schizo99
@shashank1999coder
Jul 10 2017 12:55

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

//Try it out here
var myCar =function(wheels,seats,engines) {

this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};
var myCar = new Car(2,6,3);
var myCar = new Car(3,1,2);
var myCar = new Car(4,4,2);

plz help guys its not working
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 12:56
@sjurs1 yes
Stephen James
@sjames1958gm
Jul 10 2017 12:57
@shashank1999coder See the comment - "Change this constructor" that is where the changes should go
Thomas
@sjurs1
Jul 10 2017 12:57
@SweetCodingInc Thanks! I'll go try figuring something out
CamperBot
@camperbot
Jul 10 2017 12:57
sjurs1 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: sjurs1 already gave sweetcodinginc points
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 12:57
@sjurs1 :+1:
schizo99
@shashank1999coder
Jul 10 2017 12:59
but second comment is try it here @sjames1958gm
Stephen James
@sjames1958gm
Jul 10 2017 13:00
@shashank1999coder Try out the changes to the constructor. Your use of parameters in myCar is correct, just then need to be made in Car
schizo99
@shashank1999coder
Jul 10 2017 13:02
@sjames1958gm thanks
CamperBot
@camperbot
Jul 10 2017 13:02
shashank1999coder sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8034 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 10 2017 13:02
@shashank1999coder :+1:
schizo99
@shashank1999coder
Jul 10 2017 13:02
i dont't why i make this type of mistakes
Thomas
@sjurs1
Jul 10 2017 13:05
@sjames1958gm If you don't mind me asking, how long have you been programming for?
Stephen James
@sjames1958gm
Jul 10 2017 13:06
Well, my first program I wrote back in 1975.
Frostbites
@Frostbites
Jul 10 2017 13:07
I am extremely demotivated.

function mutation(arr) {

  newArr = [];

  for (var i = 0; i <= arr[i].length; i++) {
    for (var j = 0; j < arr[i][j].length; j++) {
    newArr.push(arr[i].split(''));
    newArr.push(arr[j].split(''));
  }
  }

}

mutation(["hello", "hey"]);
Thomas
@sjurs1
Jul 10 2017 13:09
@sjames1958gm Woah, cool. And I guess you do this for a living too?
Stephen James
@sjames1958gm
Jul 10 2017 13:09
@sjurs1 Yes, still after all these years.
@Frostbites The return from the function is true/false.
There are two values in the array - you don't need a loop that array.
You need to test each character of arr[1] and return true if all are in arr[0]
(ignoring case)
schizo99
@shashank1999coder
Jul 10 2017 13:11
@sjames1958gm so u r a web developer
??
Stephen James
@sjames1958gm
Jul 10 2017 13:13
No, our product is a cloud based application. Although we are integrating Alexa and Google actions, and those use web services
So lately I have been working on backend code to support those.
In any day I will code in c++, java, javascript
Thomas
@sjurs1
Jul 10 2017 13:15
@sjames1958gm Very cool. Also I think it's great that people like you take time out of your day to help us less experienced aspiring programmers
Stephen James
@sjames1958gm
Jul 10 2017 13:15
@sjurs1 :+1:
mzlz
@mzlz
Jul 10 2017 13:21

function reverseString(str) {
// 请把你的代码写在这
return str;
}

reverseString("hello");

reverseString("hello") 应该返回一个字符串
reverseString("hello") 应该返回 "olleh".
reverseString("Howdy") 应该返回 "ydwoH".
reverseString("Greetings from Earth") 应该返回 "htraE morf sgniteerG".
Nitin
@thenm
Jul 10 2017 13:22
what is event bubbling?
mzlz
@mzlz
Jul 10 2017 13:22
help
Nick Janne
@njanne19
Jul 10 2017 13:27
@sjames1958gm what IDE do you use for java
Stephen James
@sjames1958gm
Jul 10 2017 13:27
My java is for android apps so I use android studio
Nick Janne
@njanne19
Jul 10 2017 13:28
@mzlz if you're really lost, you can start this program by thinking about ways you've learned on how to iterate through objects (Hint: i)
Stephen James
@sjames1958gm
Jul 10 2017 13:29
@thenm Its where an event is passed from the element that the event occurs on up the hierarchy to the parent elements, trying to find a handler
Nitin
@thenm
Jul 10 2017 13:30
@sjames1958gm sorry didn't get it.
Stephen James
@sjames1958gm
Jul 10 2017 13:32
@thenm If you click on some element in the HTML/DOM, the browser will look for event handlers on that element.
Then it will look to that element's parent and on up the hierarchy. This is event bubbling. Like bubbles in your soda
Diego Mayer
@Chrono79
Jul 10 2017 13:34
@mzlz show some code, you can use reverse() (it's an array method, so you'll have to convert your string to an array before using it and then convert that back to a string) or you can use a loop and build another string
Nitin
@thenm
Jul 10 2017 13:34
@sjames1958gm oh so if button is clicked and that button is nested inside some html then browser will look for an event handler for that action.. But this seem quite disadvantageous?
Stephen James
@sjames1958gm
Jul 10 2017 13:35
@thenm If the event is handled then it stops
Nitin
@thenm
Jul 10 2017 13:36
@sjames1958gm Thanks mate you guys are awesome.
CamperBot
@camperbot
Jul 10 2017 13:36
thenm sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8035 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
mzlz
@mzlz
Jul 10 2017 13:45
@Chrono79 i don't understand ,How to write?
Going backwards you can build a new reversed string
mzlz
@mzlz
Jul 10 2017 13:50
Can you write for me? Then I'll look at it as a whole,thank you! @Chrono79
CamperBot
@camperbot
Jul 10 2017 13:50
mzlz sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4474 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 10 2017 13:51
@mzlz I think it's better for you if you try writing it yourself, and it that doesn't work we can tell you what's wrong
start with creating a descending loop that uses the string length
If you're not comfortable doing that, then review those past challenges, because you'll need to use that more than once later and it's better to walk in solid ground
mzlz
@mzlz
Jul 10 2017 13:54
thank you @Chrono79
CamperBot
@camperbot
Jul 10 2017 13:54
mzlz sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: mzlz already gave chrono79 points
Diego Mayer
@Chrono79
Jul 10 2017 13:54
no problem
Michiel
@MichielHuijse
Jul 10 2017 13:59
Hi I whats wrong with this code? I want to create random rgb values to change the background color. Before I added the function in the loop everything worked out fine. Help appreciated! https://codepen.io/michiel-huijse/pen/PjOKre?editors=1111
Diego Mayer
@Chrono79
Jul 10 2017 14:03
Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function. (Google it)
else (randNum3 == 3) <- that's wrong
you missed an if there
Michiel
@MichielHuijse
Jul 10 2017 14:05
Aaah thanks
@Chrono79 thank u
Valentin
@valentinlybmin
Jul 10 2017 14:05
Hey! So I made this project in code pen , I oppened in in full window and I had an old version of the project in a new tab. At some point I must have clicked the old project to be saved overwriting the new one
Diego Mayer
@Chrono79
Jul 10 2017 14:05
:+1:
Valentin
@valentinlybmin
Jul 10 2017 14:05
Does someone know if it is possible to recover?
I have the new version open in full window mode but I cannot ssave from there
And I am not sure how to inspect the javascript so that i can copy it
Michiel
@MichielHuijse
Jul 10 2017 14:06
@Chrono79 thanks, seemed like the brownie points dissapeared :)
CamperBot
@camperbot
Jul 10 2017 14:06
michielhuijse sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4475 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 10 2017 14:06
@valentinlybmin duplicate the tab, change the view (maybe that'll work)
Valentin
@valentinlybmin
Jul 10 2017 14:07
@Chrono79 by copying the link in a new window I get the old version
Diego Mayer
@Chrono79
Jul 10 2017 14:07
@valentinlybmin not copying the url, which browser do you use?
Valentin
@valentinlybmin
Jul 10 2017 14:07
@Chrono79 chrome
Diego Mayer
@Chrono79
Jul 10 2017 14:08
right button over the tab, duplicate tab
Valentin
@valentinlybmin
Jul 10 2017 14:08
got it ,but it dosent work
gives me again the old window arrgh
Is there a way to inspect the javascript?
Diego Mayer
@Chrono79
Jul 10 2017 14:11
ctrl+shift+j or F12
Look for <div class="code-wrap">
The content of <code>
Some things are encoded there
Valentin
@valentinlybmin
Jul 10 2017 14:12
I found the script thanks
Diego Mayer
@Chrono79
Jul 10 2017 14:13
Try using forks
Valentin
@valentinlybmin
Jul 10 2017 14:13
I just have to find a way to copy it because it gives me only the option of adding break point
by clicking fork again returns me to the old version
Diego Mayer
@Chrono79
Jul 10 2017 14:13
I meant from now on
So you don't overwrite your work
Valentin
@valentinlybmin
Jul 10 2017 14:14
@Chrono79 ah right, yeah, thanks man. I gotta learn from this mistake lol
CamperBot
@camperbot
Jul 10 2017 14:14
valentinlybmin sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4476 | @chrono79 |http://www.freecodecamp.com/chrono79
makalohri
@makalohri
Jul 10 2017 14:19
@knrt10 thank you
CamperBot
@camperbot
Jul 10 2017 14:19
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @knrt10 |http://www.freecodecamp.com/knrt10
Pedro Almeida
@pmqa
Jul 10 2017 14:25
hey guys, is there a channel to speak about random meta programming stuff?
Thomas
@sjurs1
Jul 10 2017 14:41
In order to use .click() or on.("click"), does the target element need to be either a button or an anchor?
Marianissimus
@Marianissimus
Jul 10 2017 14:41
@sjurs1 as far as i know, it can be anything, even a paragraph
Thomas
@sjurs1
Jul 10 2017 14:46

@Marianissimus I thought so too, so maybe I'm doing something else wrong.

https://codepen.io/sjurs1/pen/eWaXKK

After creating <h4> and p elements, I hide all p elements at the end of the function. I thought I could add

$("h4").on("click", function() {
    $("p").toggle();
  });

in my document ready function, but nothing is happening

Thales Alexandre Ferreira Albuquerque
@Vitruvia
Jul 10 2017 14:49
Can anyone tell me why my images sometimes get stuck in this slideshow? https://codepen.io/khiv/pen/xqVdMe
It's not exactly getting stuck forever, they kind of just stutter sometimes
Marianissimus
@Marianissimus
Jul 10 2017 14:50
@sjurs1 what p? where? don't see them
you have no p in your entire html
Thomas
@sjurs1
Jul 10 2017 14:50
@Marianissimus I add them with jQuery.
function getArticles(searchWord) {
  $("#newArticle").empty(); //Empty content from previous search
  $.ajax({
    type: "GET",
    url: "https://en.wikipedia.org/w/api.php?format=json&origin=*&action=query&generator=search&prop=extracts&exlimit=10&exintro=true&explaintext=true&gsrsearch=" +
      searchWord,
    success: function(data) {
      let parentList = $("<ul/>");
      let pageids = Object.keys(data.query.pages);
      let elem = data.query.pages;
      for (let article in elem) {
        let articleTitle = $("<h4/>", {
          text: elem[article].title,
          id: "show"
        })
        let listElement = $("<p/>", {
          text: elem[article].extract,
          class: "animated fadeIn",
          style: "padding-right: 2em;"
        })
        $(listElement).hide();

        parentList.append(articleTitle,listElement);
        $("#newArticle").append(parentList);
      }
    }
  });
};
When you search for something, jQuery adds the h4 and p elements
Marianissimus
@Marianissimus
Jul 10 2017 14:52
@sjurs1 yes, but i never see them appearing first - the paragraphs, i mean. there must be your problem
Thomas
@sjurs1
Jul 10 2017 14:56
@Marianissimus Ah, so the html of the page never actually changes? There's no way to target jQuery created elements?
@Marianissimus Oh, never mind! I just had to put the toggle method inside the function itself
surferpilgrim
@surferpilgrim
Jul 10 2017 15:11
so the first chunk of my program translates the inputs into an array of strings so an input like [580] would translate into ["500","80"]. the inner function ""translator" should take that string array match the corresponding values to their roman numeral counterparts so "500" would match with "D" and "80" would match with "LXXX". the ultimate goal is to have the complete function take an input and return an array of it's matching roman values (so ["500","80"] would return ["D","LXXX"] ). This is the roman numeral algorithm challenge I'm not interested in anyone posting the answer, that's not what I'm asking for, all I'm looking for is faults in my code that I could improve so that it could return what I want. Right now the first chunk of code works fine, but my translator function keeps returning undefined when I call it
function convertToRoman(num) {
var nums = num.toString().split("");
  var  len = nums.length;
  var answer = nums.map(function(n,i){
    return n + (Array(len - i-1).fill(0)).join("");
  });
  var response = [];

function translator(answer){
var inputs ={ 
  "3000": "MMM","2000": "MM","1000": "M","900": "CM","800":"DCCC","700": "DCC","600":"DC","500":"D","400":"CD","300": "CCC","200":"CC","100":"C","90":"XC","80":"LXXX","70":"LXX","60":"LX","50":"L","40":"XL","30":"XXX", "20":"XX", "10":"X","9":"IX","8":"VIII","7":
  "VII","6":"VI","5":"V","4":"IV","3":"III", "2":"II","1": "I"};
  for(var key in inputs){
if(answer.indexOf(key)!==-1){
  response.push(inputs[key]);
  return response;
}}}
return translator();
}
 convertToRoman(36);
Stephen James
@sjames1958gm
Jul 10 2017 15:15
@surferpilgrim likely you are returning to soon in the translator, you have a parameter but don't pass anything, but you don't use it either.
This message was deleted
@surferpilgrim I missed your use of answer - since you have it as a parameter and don't pass anything it cannot see the outer answer
surferpilgrim
@surferpilgrim
Jul 10 2017 15:20
@sjames1958gm the fist chunk of code (before var response), takes in a input like 65 and the answer evaluates that as ["60","5"] , I set answer as a parameter because I wanted the string to pass through the json and return an array of roman numeral values
ALI
@alishaik8055
Jul 10 2017 15:20
can any one help me with the doubly linked list implementation in javascript
Stephen James
@sjames1958gm
Jul 10 2017 15:21
@surferpilgrim answer in the translate function is undefined. The parameter is hiding the outer variable.
Also, shouldn't you loop over the answer array, not the keys from input?
function translator(answer){ this hides or shadows the answer variable above.
surferpilgrim
@surferpilgrim
Jul 10 2017 15:22
@sjames1958gm I thought since answer was outside of translator function it would be more of a global variable than a local variable, If i understand correctly answer in the translator function is then treated as a brand new parameter
Stephen James
@sjames1958gm
Jul 10 2017 15:23
@surferpilgrim It is, but when you define answer as a parameter you are creating a new variable with the name answer which hides the other one.
@surferpilgrim return translator(answer); this would solve that problem, but having two answer 'variables' might be confusing.
surferpilgrim
@surferpilgrim
Jul 10 2017 15:24
@sjames1958gm I'm still learning, so when you create a function and set the parameter, it creates a new value even if that parameter is the name of an outside variable
Stephen James
@sjames1958gm
Jul 10 2017 15:25
Yes, a parameter is a new local variable, hiding any outside variable of the same name.
surferpilgrim
@surferpilgrim
Jul 10 2017 15:29
@sjames1958gm In general you don't pass a variable inside a parameter function translator(answer), but only when you call it so: you can make a function take an arbritary parameter function translator(apple){, and when you want to return actually have the variable pass through you just call it at the end: return translator(answer)
Stephen James
@sjames1958gm
Jul 10 2017 15:31
Yes. However, in this case, you could remove the parameter function translator() { and use answer inside the function translator.
It is a stylistic choice here.
Joseph Joe
@JoeTinnySpace
Jul 10 2017 15:34

blob

what's that numbers in bubbles. ( on console tab)?

Jason Luboff
@JLuboff
Jul 10 2017 15:36
@JoeTinnySpace Just groupings of console.log messages
Saif Ur Rahman
@saifsmailbox98
Jul 10 2017 15:36
@JoeTinnySpace multiple outputs are grouped together if they are same, it's the count.
Joseph Joe
@JoeTinnySpace
Jul 10 2017 15:37
@saifsmailbox98 @JLuboff alrighty , thanks
CamperBot
@camperbot
Jul 10 2017 15:37
joetinnyspace sends brownie points to @saifsmailbox98 and @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 746 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:star2: 2053 | @jluboff |http://www.freecodecamp.com/jluboff
Christopher McCormack
@cmccormack
Jul 10 2017 15:39
:wave: hello
Jason Luboff
@JLuboff
Jul 10 2017 15:40
Yo
Pieter Stokkink
@forkerino
Jul 10 2017 15:42
Hey hey
Christopher McCormack
@cmccormack
Jul 10 2017 15:42
@forkerino heya how has the job been?
Pieter Stokkink
@forkerino
Jul 10 2017 15:43
Good! Getting into the groove.
Christopher McCormack
@cmccormack
Jul 10 2017 15:43
I bet - they start you on anything interesting yet?
Jason Luboff
@JLuboff
Jul 10 2017 15:44
@forkerino :wave:
Pieter Stokkink
@forkerino
Jul 10 2017 15:44
Definitely. Doing a lot of Redux, also learning TDD, so that's cool too.
Stephen James
@sjames1958gm
Jul 10 2017 15:44
@forkerino Nice, I am jealous
Pieter Stokkink
@forkerino
Jul 10 2017 15:45
But was away for a few days at the end of last week
Christopher McCormack
@cmccormack
Jul 10 2017 15:45
From what I've read some companies have millions of lines of TDD code :) should be fun
Pieter Stokkink
@forkerino
Jul 10 2017 15:45
On a retreat which I already booked before
Jason Luboff
@JLuboff
Jul 10 2017 15:45
Oh...where'd you go?
Pieter Stokkink
@forkerino
Jul 10 2017 15:46
Something that would be illegal in some countries
Jason Luboff
@JLuboff
Jul 10 2017 15:46
:worried:
Christopher McCormack
@cmccormack
Jul 10 2017 15:46
Driving on the right side of the road conference?
Pieter Stokkink
@forkerino
Jul 10 2017 15:47
@cmccormack I do have the feeling sometimes i'm writing the same code twice with tdd
Sweet Coding :)
@SweetCodingInc
Jul 10 2017 15:47
That's India and UK @cmccormack
Pieter Stokkink
@forkerino
Jul 10 2017 15:47
😂 right side
Christopher McCormack
@cmccormack
Jul 10 2017 15:48
@forkerino yeah but I guess in the end if you want to be able to push out new features fast you better have tons of tests to make sure you don't break production
shivam gupta
@shivamg11000
Jul 10 2017 15:48
:wave:
all
Christopher McCormack
@cmccormack
Jul 10 2017 15:48
@shivamg11000 hello
Pieter Stokkink
@forkerino
Jul 10 2017 15:48
Exactly @cmccormack
@JLuboff no need to worry, it was amazing
Jason Luboff
@JLuboff
Jul 10 2017 15:50
@forkerino Well glad you had a good time. Any word from @HeebieGeeBee ?
shivam gupta
@shivamg11000
Jul 10 2017 15:50

so I was building a simple todo app with react ,I came to an unexpected error in it which was solved with

_unique.id()

which is method of underscore.js , used to generate the keys of list items,
I have no clue

Pieter Stokkink
@forkerino
Jul 10 2017 15:51
@JLuboff nope
Christopher McCormack
@cmccormack
Jul 10 2017 15:52
@shivamg11000 was it an error or a warning?
shivam gupta
@shivamg11000
Jul 10 2017 15:52
@cmccormack It was a bug that was unexpected
Jason Luboff
@JLuboff
Jul 10 2017 15:53
@forkerino Strange. Well hope all is well with him. Maybe he just wanted nothing to do with us anymore :joy:
Pieter Stokkink
@forkerino
Jul 10 2017 15:53
Let's hope so
Christopher McCormack
@cmccormack
Jul 10 2017 15:53
Well when adding a list of items all keys should be unique and not use the index value. That would give a warning though, not necessarily an error. What was your error?
Stephen James
@sjames1958gm
Jul 10 2017 15:54
@cmccormack Why not the index value?
Pieter Stokkink
@forkerino
Jul 10 2017 15:54
@shivamg11000 you can also just assign a key to all list items... no need for underscore
Christopher McCormack
@cmccormack
Jul 10 2017 15:55
@sjames1958gm I believe the key is used internally to identify the DOM elements. An index could probably work fine but if something changes but the list order doesn't the element may never get updated
I haven't dug too deep into it though
manuchehr94
@manuchehr94
Jul 10 2017 15:56

var Person = function(firstAndLast) {
  // Complete the method below and implement the others similarly

  var firstName = firstAndLast.split(" ")[0]; 
  var lastName = firstAndLast.split(" ")[1]; 

  this.getFullName = function() {
    return firstAndLast;
  };

  this.getFirstName = function() {
    return firstName; 
  }; 

  this.getLastName = function() {
    return lastName;
  }; 

  this.setFirstName = function(first) {
      firstName = first; //???
  }; 

  return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();
Salut. How can I set first name?
Stephen James
@sjames1958gm
Jul 10 2017 15:57
@manuchehr94 that looks correct
Joel Y.
@zapcannon99
Jul 10 2017 15:57
wouldn't it be just bob.setFirstName(newname) ?
manuchehr94
@manuchehr94
Jul 10 2017 15:57
@sjames1958gm it's not passing the test
Joel Y.
@zapcannon99
Jul 10 2017 15:58
Oh nvm
Christopher McCormack
@cmccormack
Jul 10 2017 15:58
@manuchehr94 you tried using this for the variables?
Joel Y.
@zapcannon99
Jul 10 2017 15:58
^^^
Stephen James
@sjames1958gm
Jul 10 2017 15:58
@manuchehr94 shouldn't you return this from the constructor?
@cmccormack variables are supposed to be private
shivam gupta
@shivamg11000
Jul 10 2017 15:58
@forkerino @cmccormack see this , It is expected to have a line-through on first click and on second click the todo should vanish, on second click the clicked item vanishes but the todo immediately after lines-through that was the bug in it
https://codepen.io/shivamg11000/pen/rwQzjb?editors=0010