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
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
those are called ternary expressions
it's just a shortcut way of doing if/else
condition ? true : false
that's how it works
Abdijabar Yussuf Mohamed
@aymohamed
Any hint on how I can better show "my copyright " and link my tribute page to an external website : https://codepen.io/aymohamed/pen/egWgmQ
JD Tadlock
@jdtdesigns
lol @aymohamed
You can add padding and background to the copyright
and just add a hyperlink
<a href="https://google.com" target="_blank">Google</a>
Abdijabar Yussuf Mohamed
@aymohamed
does that mean I use a div class ?
JD Tadlock
@jdtdesigns
just add a class to the div wrapping the copyright
and use that class in the css
Abdijabar Yussuf Mohamed
@aymohamed
Ok. Let me try that and I will get back to you. @ JD Tadlock. Thanks
@jdtdesigns, can the wrapper class have any name or just "container" etc?
JD Tadlock
@jdtdesigns
it can be any name @aymohamed
they need to be space separated
<div class="my-class row another-class one-more"></div>
Abdijabar Yussuf Mohamed
@aymohamed
Ok. Thanks @jdtdesigns .I am doing that now
CamperBot
@camperbot
aymohamed sends brownie points to @jdtdesigns :sparkles: :thumbsup: :sparkles:
:cookie: 879 | @jdtdesigns |http://www.freecodecamp.com/jdtdesigns
h1tag
@h1tag
@jdtdesigns Thank you for help and spending the time writing the code :smile: Although I didn't ask about the "clearing" part but you knew I'm gonna' ask about later, right? ;) :p
CamperBot
@camperbot
fortmaximus sends brownie points to @jdtdesigns :sparkles: :thumbsup: :sparkles:
:cookie: 880 | @jdtdesigns |http://www.freecodecamp.com/jdtdesigns