These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Sep 2017
christopher clarke
@chrisdclarke
Sep 14 2017 00:05

hey guys im having a hard time figuring out why my ajax call wont work ... any idea??? document.getElementById("get_quote").onclick = function(){

$.ajax({
url: "https://CORS-Anywhere.HerokuApp.com/http://http://labs.bible.org/api/?passage=random",
success: function(data) {
console.log(data);
document.getElementById("quote").innerHTML=data;
}
});
}

korzo
@korzo
Sep 14 2017 00:14
@chrisdclarke Uncaught TypeError: Cannot read property 'isValidElement' of undefined
christopher clarke
@chrisdclarke
Sep 14 2017 00:15
hey... so what does that mean.. lol? @korzo
korzo
@korzo
Sep 14 2017 00:15
@chrisdclarke Looks like some error in React
@chrisdclarke If you get rid of react, it works, but URL is wrong (404)
@chrisdclarke duplicate http
christopher clarke
@chrisdclarke
Sep 14 2017 00:21
thanks @korzo so much good catc
CamperBot
@camperbot
Sep 14 2017 00:21
chrisdclarke sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 483 | @korzo |http://www.freecodecamp.com/korzo
christopher clarke
@chrisdclarke
Sep 14 2017 00:22
i was bustin my head tryin to find the bug ,
korzo
@korzo
Sep 14 2017 00:24
@chrisdclarke Yeah, that's a type of bug hard to catch by author
Gerald Tapiwa Moyo
@microfacticalGtm
Sep 14 2017 01:17
hi geeks am on javascript challenge which needs me to change text inside an element i have resetted my code over and over again but it is not working.
Gersho
@Gersho
Sep 14 2017 01:17
what's the challenge name ?
Gerald Tapiwa Moyo
@microfacticalGtm
Sep 14 2017 01:19
change text inside an element here is my 'code'
<script>
$(document).ready(function() {
$("#target1").css("color", "red");
$("#target4").html("<em></em>")
});
</script>
Gersho
@Gersho
Sep 14 2017 01:22
oh, you are really close
look at the representation in the phone, do you notice a problem ?
there is one very small button, because it has no test
using .html() you specify a new content, the old content does not exist anymore
you should put text inside your <em></em>
$("#target4").html("<em>#target4</em>");
Gerald Tapiwa Moyo
@microfacticalGtm
Sep 14 2017 01:25
ok let me try
Gersho
@Gersho
Sep 14 2017 01:26
oh and when you paste code, you should add 3 ` before and after it(on a separate line), it will be easier to read, like so:

<script>
  $(document).ready(function() {
    $("#target1").css("color", "red");
    $("#target4").html("<em>#target4</em>");
  });
</script>
Gerald Tapiwa Moyo
@microfacticalGtm
Sep 14 2017 01:26
thanks it worked you are a genius!!!!
Janelle deMent
@janelledement
Sep 14 2017 01:32
Sum_All_Numbers_in_a_Range___freeCodeCamp.png
can anyone tell me why I'm getting null in the above screenshot?
Moisés Man
@moigithub
Sep 14 2017 01:33
cuz mathmin requires a list of numbers.. u passing an array
Math.max(1,2,2,3,4)
NOT Math.max([1,2,2,3,4])
Janelle deMent
@janelledement
Sep 14 2017 01:34
Ohhhhh @moigithub thanks!
CamperBot
@camperbot
Sep 14 2017 01:34
janelledement sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3631 | @moigithub |http://www.freecodecamp.com/moigithub
mm1mm2
@mm1mm2
Sep 14 2017 02:13
image.png
image.png
What's the problem?
Moisés Man
@moigithub
Sep 14 2017 02:21
mdn.io/substr @mm1mm2
korzo
@korzo
Sep 14 2017 02:23
@mm1mm2 You have wrong parameters for substr
first parameter is start and second length
@mm1mm2 With -1 as 1.parameter, it always take only last letter
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:03
is there an "and" command in regular expression? i know there's an "or" but is there an and also?
Claudio Restifo
@Marmiz
Sep 14 2017 03:06
@BrianWilliams28 afaik not really. You can however search for a match and for a second match, but needs to be in order
or you concatenate two regex
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:07
@Ellyria thanks
CamperBot
@camperbot
Sep 14 2017 03:07
brianwilliams28 sends brownie points to @ellyria :sparkles: :thumbsup: :sparkles:
:cookie: 506 | @ellyria |http://www.freecodecamp.com/ellyria
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:08
@Marmiz you mean including everything in 1 square bracket?
Ellyria
@Ellyria
Sep 14 2017 03:08
Any time, @BrianWilliams28. I hope it works! I didn't test it.
Daniel
@DanJP2016
Sep 14 2017 03:13
i am playing around with ideas for the twitch viewer project and working on a particle emitter, but whenever the screen resizes the canvas flashes white. is there anyway to stop that?
https://codepen.io/bones211/pen/MEYoMd?editors=0010
Claudio Restifo
@Marmiz
Sep 14 2017 03:14
@BrianWilliams28 Dunno why you would need square brackets for that.
I was thinking more of a:
/(?=.*search1)(?=.*search2) .... /
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:14
@Marmiz ok, but what's with the . after ?=?
Ellyria
@Ellyria
Sep 14 2017 03:18
Very pretty, @DanJP2016! Try adding the background color of black to the body and/or the canvas. It still has a very slight flicker on my screen when I do that, but it's much better.

function isLess(a, b) {
// 请修改这部分代码
return a === b;
}

// 你可以修改这一行来测试你的代码
isLess(10, 15);

我这样写有什么不对嘛?
Daniel
@DanJP2016
Sep 14 2017 03:20
@Ellyria ah thank you. I didn't even think to try that I though there was something off in my javascript lol
CamperBot
@camperbot
Sep 14 2017 03:20
danjp2016 sends brownie points to @ellyria :sparkles: :thumbsup: :sparkles:
:cookie: 507 | @ellyria |http://www.freecodecamp.com/ellyria
Ellyria
@Ellyria
Sep 14 2017 03:21
Does it still flicker just a little bit for you when you try it, @DanJP2016? It may just be what canvas does or it may have to do with all those glitzy colorful animations you have.
Daniel
@DanJP2016
Sep 14 2017 03:23
yeah there is a still a slight flicker. not as bad as that blast of retina searing white though
Ellyria
@Ellyria
Sep 14 2017 03:28
@xiaming5368, please forgive my Chinese. I used Google Translate:
您的功能是对两个变量进行严格的比较,它将返回一个真实或错误的结果。 当你给它10和15作为变量值,它返回false。 对我来说看起来完美。
Yeah, heh, it's definitely better, but I was wondering whether the flicker that remained was due to my hardware or the code. Since you still see a slight one, too, I guess it's in the code.
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:29
can someone help? i am trying to match the two brackets in the string '1 (555) 555-5555' but only if they enclose three numbers. so far i created the regex ( for the 1st bracket but not sure how to check for the 2nd too.
'('
/(/g
zzz
squareBracket(squareBracket(?=\d{3})
Ellyria
@Ellyria
Sep 14 2017 03:32
This page looks frightening enough that it should contain what you're after, @BrianWilliams28: https://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation
Ellyria @Ellyria is way too tired to try to make sense of everything on that page.
Ellyria
@Ellyria
Sep 14 2017 03:34
I couldn't resist looking through it all. There's a Quick cheat sheet section on that page that should do you quite nicely.
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:35
interesting
they suggest removing all the values that arent numbers
Gersho
@Gersho
Sep 14 2017 03:36
@BrianWilliams28 that wouldn't work, because some of the values have indeed the good number of digits, but are formated poorly
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:36
yeah
i was ganna say
the misplaced brackets need to return false
Ellyria
@Ellyria
Sep 14 2017 03:37
I noticed that several people's solutions don't check for the proper number of numbers. I'd steer clear of those. If you're gonna validate it, you may as well be strict.
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:39
trying to be as strict as possible
Ellyria
@Ellyria
Sep 14 2017 03:39
That's the best way.
Gersho
@Gersho
Sep 14 2017 03:39
there's also the issue of those with an international indicator
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:39
but my experience with regex's are limited and this seems to require in depth knowledge
experimenting with regex101 but not finding exactly what i need
Ellyria
@Ellyria
Sep 14 2017 03:40
Yeah, my brain can't rumble too heavily around in regex when bed is calling.
Ah, you're talking about the +1 and all that, right, @Gersho?
Gersho
@Gersho
Sep 14 2017 03:41
yes
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:41
have you completed this one?
Ellyria
@Ellyria
Sep 14 2017 03:41
I just noticed those for the first time this week.
Which one is it?
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:41
the 1st advanced algorithm challenge
Gersho
@Gersho
Sep 14 2017 03:41

by the way, i have an issue too ^^

  function validSolution(board){
    blockTest.apply(undefined,board);

    function blockTest(arr){
      consolelog("arr",arr);


    }//end blockTest
  }//end validSolution

board is a 2D array, but blockTest() is called only once, for board[0]

Ellyria
@Ellyria
Sep 14 2017 03:41
Nope. I'm still stuck in intermediate algorithm land.
Gersho
@Gersho
Sep 14 2017 03:42
@BrianWilliams28 by the way i'm glad to see you ended up winning your fight with steamroller ;)
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:42
@Gersho lol dude
Ellyria
@Ellyria
Sep 14 2017 03:42
What's your issue, Gersho?
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:42
dont even get me started
its funny because some of the intermediate ones i got in 5 minutes
others took me days
like that one
Ellyria
@Ellyria
Sep 14 2017 03:43
Yeah, I'm on the Wikipedia project and I stopped in my tracks and switched to Udemy temporarily. I'm working my way through the Udemy course first and then coming back to fCC to continue. I figure that will make me more likely to understand some of this stuff.
Gersho
@Gersho
Sep 14 2017 03:44
yeah i took me one week :P
@Ellyria blockTest is called only once, shouldn't it be called once for each item in board ? like board[0] then board[1] etc
Ellyria
@Ellyria
Sep 14 2017 03:45
The Wikipedia project?
I'm not sure. Have you tried doing a loop?
Gersho
@Gersho
Sep 14 2017 03:45
no that's my issue
i haven't, wanted to do it with apply but i must be using wrong i guess
i'll just use foreach
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:47
oh
yeah i copied a lot for those
i just didn't know enough javascript at the time
now i feel like like i could do them again on my own
im actually starting to feel like im learning more javascript than html/css now
Claudio Restifo
@Marmiz
Sep 14 2017 03:49

@Ellyria The pain is the Wikipedia API that is pretty much hard to read and understand.
the project itself is quite easy to be honest ( I think Twitch has a harder requirement.)

That's why the wikipedia will be moved as facultative in the new fcc version

Gersho
@Gersho
Sep 14 2017 03:50
it should be, since it's the doc, but i think i have a PBKAC issue
@Ellyria
Ellyria
@Ellyria
Sep 14 2017 03:50
Yeah, I got annoyed because I had just been annoyed by the weather API not all that long before the Wikipedia one, and when I get annoyed, I start looking around, and Udemy caught my eye. I'll be back, though. I'm determined to complete fCC.
Heh.
Those are a drag.
Gersho
@Gersho
Sep 14 2017 03:51
especially when you're the one in the chair
Ellyria
@Ellyria
Sep 14 2017 03:51
Yeah. It's better when it's somebody else, for sure.
You might be able to have an out of body experience and solve it.
Claudio Restifo
@Marmiz
Sep 14 2017 03:51
@BrianWilliams28 here's a regex that matches 3 5 inside a ()
https://regex101.com/r/OMCnFF/1
Gersho
@Gersho
Sep 14 2017 03:52
@Ellyria one day i actually had an idea in my sleep to the point it woke me up
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:52
@Marmiz the numberts arent going to be 5 every time though, they can be random
Ellyria
@Ellyria
Sep 14 2017 03:52
Yes, that happens to me all the time! I love it! I keep a notebook next to the bed for that reason!
Gersho
@Gersho
Sep 14 2017 03:53
i got up and turned on the computer :p
Ellyria
@Ellyria
Sep 14 2017 03:53
Heh, that will work, too.
Claudio Restifo
@Marmiz
Sep 14 2017 03:53
@BrianWilliams28 well, I can't do all the work for you ;P
BrianWilliams28
@BrianWilliams28
Sep 14 2017 03:54
@Marmiz why not? =P
j/k
刘国钧
@liuguojin2017
Sep 14 2017 05:45
hello everyone
Jake
@JakeDVirus
Sep 14 2017 07:17
can anyone help me figure out why my statement in line-73 is not working but the statement in line-67 do work(which is commented out in the code to work on line-73).
The context is about $(abc).appendTo() method, which on line-67(working) the abcis individual element while on line-73(not working) the abc is an array of elements.
https://codepen.io/neel111/pen/oeKGJL?editors=0011
Sandip Shrestha
@saninmersion
Sep 14 2017 08:51
@NeelDVirus it's a callback hell kind of thing. The data you get on success on line 63 can only be used inside the call back function of that success like that. Since JS is asynchronous(i.e. does not wait for a particular block of code to complete executing before going to the next.) the code you write on line 73 will be interpreted even before yo get data from success on line 63.
bilaal-s
@bilaal-s
Sep 14 2017 09:33
hello good folks
its been too long. will be more consitent with fcc.
is my calculator solution oversimplistic?
Jake
@JakeDVirus
Sep 14 2017 09:34
@saninmersion oh yeah i got you point. i missed that point. any suggestion how and at what point i shall append the cloneList
Chris Juchtmans
@kjuchtmans
Sep 14 2017 09:36
greetings all coders! :wave:
@bilaal-s looks neat ! like I would want to pick it up from my screen :smile:
am working on the same project, and I find these features useful:
  1. overflow: when series of digits enteres exceeds screen size, wrap, or resize font
  2. thousands separator
  3. positive / negative symbols
    Great work though!
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 09:41
hey guys need a little help
    $(window).scroll(function() {
      if ($(window).scrollTop() > 200) {
          $("nav").addClass("active");
      }
      else {
          $("nav").removeClass("active");
      }
  });
this works perfectly with the scroll but if I refresh the webpage and it starts at middle there is no scroll yet so it wont add the class, any work around on this you can point?
bilaal-s
@bilaal-s
Sep 14 2017 09:46
@kjuchtmans thank you!
CamperBot
@camperbot
Sep 14 2017 09:46
bilaal-s sends brownie points to @kjuchtmans :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @kjuchtmans |http://www.freecodecamp.com/kjuchtmans
Jake
@JakeDVirus
Sep 14 2017 09:48
@saninmersion i made the cloneList to get appended inside success method itself. but still no good
Its working now.
but its working if i use $(container).append(cloneList) but dont work when used $(cloneList).appendTo(container), where cloneList is an array of elements and text nodes
Stephen James
@sjames1958gm
Sep 14 2017 10:01
@tiagocorreiaalmeida can you in your document ready function check scrollTop and set the class correctly?
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 10:18
@sjames1958gm having troubles trying to figure out how to do that
Stephen James
@sjames1958gm
Sep 14 2017 10:20
You could put that code into a named function and call it at the end of your document ready callback.
function checkScroll() {
      if ($(window).scrollTop() > 200) {
          $("nav").addClass("active");
      }
      else {
          $("nav").removeClass("active");
      }
  })
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 10:23
thanks mate
another question a website with a header as text looks really bad I used a devicon icon from atom I think there's no problem or you think there is?
Stephen James
@sjames1958gm
Sep 14 2017 10:32
@tiagocorreiaalmeida I guess it depends on the licensing for the icon.
If that is the point of your question
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 10:47
http://konpa.github.io/devicon/ I can't understand but from what I saw I can reuse it right?
Stephen James
@sjames1958gm
Sep 14 2017 10:51
@tiagocorreiaalmeida yeah MIT license is pretty wide open
Pavlo Rudyi
@paulcarroty
Sep 14 2017 10:53
if (postTitles[i].toLowerCase().indexOf('str1l') != -1     

|| postTitles[i].toLowerCase().indexOf('str2') != -1

 || postTitles[i].toLowerCase().indexOf('str3') != -1 

|| postTitles[i].toLowerCase().indexOf('str4') != -1)
     { }
Hey people, can I write this code in more compact and readable style?
Stephen James
@sjames1958gm
Sep 14 2017 10:54
@paulcarroty A regex would probably work better
Pavlo Rudyi
@paulcarroty
Sep 14 2017 10:55
@sjames1958gm regexp yep, but I have ~400 titles and regexps will slow my code.
Stephen James
@sjames1958gm
Sep 14 2017 10:55
More so than all those indexOf?
Pavlo Rudyi
@paulcarroty
Sep 14 2017 10:58
@sjames1958gm yep. The idea in checking all titles for some content and grab only interesting titles.
Stephen James
@sjames1958gm
Sep 14 2017 11:01
First pull the postTitles[i].toLowerCase() into a variable so you don't do it every time.
Then you could put the strings into an array and use an array function like .some
let t = postTitles[i].toLowerCase()
['str1', 'str2', 'str3'].some(str => t.indexOf(str) !== -1)
Abhinav Mishra
@abhinav-m
Sep 14 2017 11:10
is this colour scheme awful?
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 11:10
thanks @sjames1958gm for always take your time into my problems
CamperBot
@camperbot
Sep 14 2017 11:10
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8462 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abhinav Mishra
@abhinav-m
Sep 14 2017 11:10
i feel the one on fcc's project is the best one to use
how can i go about choosing a better colour scheme
nathanl127
@nathanl127
Sep 14 2017 11:11
Hello there I am very autustic
*artistic
I can help you with your color scheme
Firstly, get rid of that mud green
Abhinav Mishra
@abhinav-m
Sep 14 2017 11:13
ok what do i replacce it with
nathanl127
@nathanl127
Sep 14 2017 11:13
Can you briefly explain to me your data
What does mud green indicate i.e. compared to that pale orange
nathanl127
@nathanl127
Sep 14 2017 11:15
That colour scheme <3
Radiates
Do you see how all of those colours have something in common?
They radiate a warmth, a yellow
Abhinav Mishra
@abhinav-m
Sep 14 2017 11:16
hmm i guess i should use the same
nathanl127
@nathanl127
Sep 14 2017 11:16
The only colours that work in your colour scheme are you 2 most common wons, and that cause they remotely have the same colour
Daniel Romero
@Ranacode
Sep 14 2017 11:45
Hey guys
I want to do a smooth scrolling to specific id section when I click a nav link item
Do you have an example on codepen?
Daniel Romero
@Ranacode
Sep 14 2017 11:57
Nothing, I got it
bilaal-s
@bilaal-s
Sep 14 2017 12:03
image.png
any idea whats going on there guys?
Ahmad Abdolsaheb
@ahmadabdolsaheb
Sep 14 2017 12:04
hey, everyone. I am trying to display items from api calls using redux/react. but I am not sure where to make the api calls. should I make api calls in a reducer or should I make an action?
I am thinking of the following data flow but I am not sure. an action get the data from the api, and then change the store state, then I use mapstate to props to display the result in a component ...
Morchid Chellali
@Morched23MJ
Sep 14 2017 12:32
@bilaal-s, can you give the pen's link instead?
Moisés Man
@moigithub
Sep 14 2017 12:34
on click requires u to pass a function as handler
u passing setInterval method instead
bilaal-s
@bilaal-s
Sep 14 2017 12:57
@Morched23MJ yes sorry for late reply
Simon Cordova
@gbsimon87
Sep 14 2017 13:00

Hey guys!

Anybody have any idea how to clone an elements behaviour?

bilaal-s
@bilaal-s
Sep 14 2017 13:04
@moigithub thanks
CamperBot
@camperbot
Sep 14 2017 13:04
bilaal-s sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3633 | @moigithub |http://www.freecodecamp.com/moigithub
Markus Kiili
@Masd925
Sep 14 2017 13:20
@gbsimon87 Do you mean event listeners?
Simon Cordova
@gbsimon87
Sep 14 2017 13:21

Hey @Masd925

I've got a navigation bar on a website which I'm trying to clone and append to a div on the page...
I'm using clone(true) but I've noticed my clicks on the cloned element affect the navigation as well

And yes sorry, I mean event listeneres
Markus Kiili
@Masd925
Sep 14 2017 13:23
@gbsimon87 cloneNode clones the attributes and inline listeners. I don't think that copying the event listeners assigned otherwise is possible. You need to refactor the code.
Simon Cordova
@gbsimon87
Sep 14 2017 13:24
image.png
@Masd925
Stephen James
@sjames1958gm
Sep 14 2017 14:07
@ahmadabdolsaheb The examples I have seen the api calls are in the actions where the actions return functions not simple objects
Markus Kiili
@Masd925
Sep 14 2017 14:38
@gbsimon87 Libraries might have something suitable.
Simon Cordova
@gbsimon87
Sep 14 2017 14:40
So far I found a way around it, I cloned the originally cloned element and it's working out so far
John Wilfred
@ewojjowe
Sep 14 2017 14:42
Hello all
does anyone here have used Osmosis on scraping websites?
Mauricio Londoño
@mauricio1585
Sep 14 2017 16:13

Hello people, help to analyze this JS function:

function createFunctions(){

var arr = [];  

for(var number = 1; number <= 3; number++){

    arr.push( 

    (function(number){

        return function(){

            console.log(number);
        }
    })(number)

    ); 
}

return arr; 

}

var functions = createFunctions();

functions0;
functions1;
functions2;

What the function does is creating new functions and group them within an array called arr. Then within a for loop I assign different values to the variable number and create a local context within the method push to print in console the number given by the function. What I don't specifically understand well is this notation:

( function(number){
return function( ) {
console.log(number);
}
} )(number)

Why I pass the parameter outside of the anonymous function? How does it work? Thank you.

Moisés Man
@moigithub
Sep 14 2017 16:15
Will White
@willnwhite
Sep 14 2017 16:33
@mauricio1585
( function(number){
return function( ) {
console.log(number);
}
} )(1) // returns function( ) { console.log(1); }
Moisés Man
@moigithub
Sep 14 2017 16:51
the purpose of IIFE is to keep number value on a function scope.. so when u invoke/call the function u get the correct value when the function were created, cuz the closure
without IIFE ..same result can be acomplished using let instead of var
Blauelf
@Blauelf
Sep 14 2017 17:20
Either the test case is wrong (missing . after H), or the task requires something more like
function abbrevName(name){
  const splitStr = name.split(" ");
  return splitStr.map((str, i) => {
    return str.charAt(0);
  }).join(".")
}

Test.assertEquals(abbrevName("Sam Harris"), "S.H”);
Brian
@BrianCodes33
Sep 14 2017 17:20
thanks @Blauelf
CamperBot
@camperbot
Sep 14 2017 17:20
briancodes33 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4604 | @blauelf |http://www.freecodecamp.com/blauelf
Brian
@BrianCodes33
Sep 14 2017 17:21
still failed some tests
Expected: 'G.C', instead got: 'g.c'
Expected: 'M.M', instead got: 'm.m'
Expected: 'E.D', instead got: 'e.d'
Expected: 'R.W', instead got: 'r.w'
Blauelf
@Blauelf
Sep 14 2017 17:21
.toUpperCase()
Brian
@BrianCodes33
Sep 14 2017 17:22
gracias señor
this one looks a little better
function abbrevName(name){

  var nameArray = name.split(" ");
  return (nameArray[0][0] + "." + nameArray[1][0]).toUpperCase();
}
Blauelf
@Blauelf
Sep 14 2017 17:23
Works for names consisting of exactly two parts.
Sue
@coding-sue-true
Sep 14 2017 18:13
Hi everyone, I need some help
Jason Luboff
@JLuboff
Sep 14 2017 18:14
With?
Sue
@coding-sue-true
Sep 14 2017 18:15
creating a list with angular
do you know anything about it?
Jason Luboff
@JLuboff
Sep 14 2017 18:16
I am not familar with angular, sorry
Sue
@coding-sue-true
Sep 14 2017 18:16
that's fine, thank you @JLuboff
CamperBot
@camperbot
Sep 14 2017 18:16
coding-sue-true sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2199 | @jluboff |http://www.freecodecamp.com/jluboff
Jake
@JakeDVirus
Sep 14 2017 18:44

there is an unsual behaviour. i am working on twitch.tv challenge. my project seems all fine but if the username of the online streamer is clicked (it will redirect to the twitch.tv app) then in the console there pops out a too long list of same error indicating.

Uncaught TypeError: event.data.indexOf is not a function
at receiveMessage (scriptTagContext.js:122)"

https://codepen.io/neel111/pen/oeKGJL?editors=1111
i dont know about codepen console, i was debugging in browser console after changing the view to "debug mode" in codepen and it was shown there.
shall i be concerned with those error? i am being blunt here

BrianWilliams28
@BrianWilliams28
Sep 14 2017 18:48
Can someone help? I am working on the telephone number algorithm and i've hit a road block. my code is below...
function telephoneCheck(str) {
  str = str.replace(/\s/g, '');
   // check if string has 10 or 11 numbers
  let match = str.match(/\d/g);
  let bracketMatch = str.match(/[()]/g);
  let dashMatch = str.match(/-/g);
  let numTest = /\d{10}/g.test(str);
  console.log(bracketMatch.length);
  // generating regex to check for appropriate number patterns
  let dash = /\b-/g;
  let areaCode = /\([0-9]{3}\)/g;
// 1st check to see if the number is simply 10 digits without any spaces or brackets, if so returns true
  if (match.length === 10 && numTest) {
    return true;
// 2nd check to see if the number contains a "(", if so it matches "()" with any 3 numbers in it and returns true if there are only two brackets in the string
  } else if (match.length === 10 && bracketMatch.length === 2) {
    // if there are no brackets the code returns an error because it can't read a null length?!
    if (areaCode.test(str)) {
      return true;
    }
  } else if (match.length === 10 && dashMatch.length <= 3) {
    if (dash.test(str)) {
      return true;
    }
  }
  return false;
}
console.log(telephoneCheck("(555)555-5555")); // works
telephoneCheck("555-555-5555"); // doesn't work
apologies its long and kinda messy, but basically it's telling me that if the string doesn't contain a bracket match it returns an error and stops working. but i don't understand why this stops the next else if statement from executing?
legendinraze
@legendinraze
Sep 14 2017 19:18
Can someone help me with next in line?
I mean stand in line
Jason Luboff
@JLuboff
Sep 14 2017 19:19
@legendinraze What do you have so far?
legendinraze
@legendinraze
Sep 14 2017 19:19
Nothing I dont just don't get it
typo
Jason Luboff
@JLuboff
Sep 14 2017 19:19
Ok.. you need to use two array methods that you recently learned about (push, pop, unshift, shift). Revisit those challenges and determine which two to use
legendinraze
@legendinraze
Sep 14 2017 19:20
ok
thx
Slitherings
@Slitherings
Sep 14 2017 19:45

Can i get some help on this code? Trying to figure if a loop is really needed to truncate the new string.

function truncateString(str, num) {
  // Clear out that junk in your trunk
  var emptyString = "";
  while(num > 0){
    emptyString = str.slice(num);
    num--;
  }
  return emptyString;
}

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

In the Console im geting "-tisket a-tasket A green and yellow basket"
and instead of truncating from the back its truncating from the front.

Jason Luboff
@JLuboff
Sep 14 2017 19:51
@Slitherings Ya.. becuase you're telling it str.slice(11) so its slicing at index 11, then youre replacing that with str.slice(10) etc. Perhaps you want to slice from starting index to num but you keep overwriting emptyString every loop
Slitherings
@Slitherings
Sep 14 2017 19:56
alright every other FCC chat is 2 lit right now
give me a sec
hmm now i have to try to change all the stuff ive done
Jason Luboff
@JLuboff
Sep 14 2017 20:01
There's no need to use a loop, I'll throw that out there
In fact...you just need some if/else if statements to account for the three different possibilities
Saikat-Sinha
@Saikat-Sinha
Sep 14 2017 20:15
How to replace one HTML tag with another?
for example in this case, I am trying to replace <blank></blank> with <span></span> but it replaces only <blank> with <span> but not </blank> causing issues
function replaceHTML(text) {

 var beginRegExp = /<blank(?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*\s*\/?>/gm

var endRegExp = /<\/blank>/gm

if(text === false){
          return ' '
        }

 else{
            return String(text).replace(beginRegExp, '<span>') 
        }
      }
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 22:41
so doesnt slice affets the str that gets applied on?
result.slice(0,1);
does nothing
but if I set a variable to that
it will return the value I removed
Jason Luboff
@JLuboff
Sep 14 2017 22:41
@tiagocorreiaalmeida ...read the first sentence from the docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
Tiago Correia
@tiagocorreiaalmeida
Sep 14 2017 22:43
its been a while :D time to read some cdn to achieve what I want, tanks
thanks