Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Ritvars
@RitvarsZ
@fortMaximus I think that there is no wrong way. Use .append or .html or whatever fits your needs
John Nunns
@johnnunns
Regexp is not defined
JD Tadlock
@jdtdesigns
@fortMaximus var link = $('</ li>');
it's RegExp not Regexp
@johnnunns
John Nunns
@johnnunns
passing 1 of 3!
pretty good! :) haha
h1tag
@h1tag
@jdtdesigns then how do I add it to html file/code?
John Nunns
@johnnunns
weird though man it's working just fine. But I'm failing at :
should_return_an_object_where_each_property_gives_a_word_in_the_string_with_its_number_of_appearances
should_return_an_object_empty_object_ifpassed
JD Tadlock
@jdtdesigns
@fortMaximus sorry, that's 2.1
in version 3 just use $('h1');
@fortMaximus what are you trying to do?
@johnnunns Show me some test cases they are passing to your function
John Nunns
@johnnunns
found the error not sure how to fix
'ask a bunch get a bunch' returns - { ask: 1, a: 3, bunch: 2, get: 1 }
so it's returning 'a' 3 times
JD Tadlock
@jdtdesigns
correct
cause a is a word
and it's in there 3 times :D
o wait
2 times
h1tag
@h1tag
@jdtdesigns I'm on the Wiki Viewer project, and I want add the links I get from the response (links to wiki pages) from the API to the html file as paragraphs or list elements
John Nunns
@johnnunns
yeah weird right? @jdtdesigns
JD Tadlock
@jdtdesigns
@johnnunns Here's a way to overcome that bug
var regex = new RegExp('(' + word + ')', 'g'),
  amount = str.match(regex).length,
  output = amount < 2 ? amount : 
    word.length < 2 ? amount - 1 : amount;
John Nunns
@johnnunns
how'd you go about figuring that out?
JD Tadlock
@jdtdesigns
coded it out just now :D
John Nunns
@johnnunns
I want to know the thought process behind it
JD Tadlock
@jdtdesigns
did it work?
that's the first question lol
John Nunns
@johnnunns
amount is not defined
JD Tadlock
@jdtdesigns
result[word] = output;
John Nunns
@johnnunns
function countWords(str) {
    if(str.length===0){
        return {};
    }
    return str.split(' ')
    .reduce(function(result, word){
        var regex = new RegExp( '(' + word + ')', 'g');
        output = amount < 2 ? amount : 
        word.length < 2 ? amount - 1 : amount;
        result[word] = output

      return result;
    },{})

}

countWords("ask a bunch get a bunch")
still says amount is not defined
JD Tadlock
@jdtdesigns
@fortMaximus this is a typical way of first clearing the old results then adding the new:
var output = $('.output');

output.empty();

output.append(
  '<a href="wiki link">' +
    '<h3>' + data.title + '</h3>' +
    '<p>' + data.content + '</p>' +
  '</a>'
);
the append would be in the data iteration of course
you would loop through the returned object and append each link
@johnnunns You left this line out that goes above output = amount....
 amount = str.match(regex).length,
you don't need the if (str.length.....) line
the reduce will return an empty object if the string is empty automagically
John Nunns
@johnnunns
that one works!
yeah added it just so I could pass one of the tests it wasnt passing
yeah still it actually doesnt work without if statement
{ '': 1 }
it's counting
Abdijabar Yussuf Mohamed
@aymohamed
Any hint on how I can better show "my copyright " and link my tribute page to an external website
JD Tadlock
@jdtdesigns
have you looked up ternaries yet? @johnnunns
John Nunns
@johnnunns
nope I will though
JD Tadlock
@jdtdesigns
that's what i'm using to do that ? blah : something