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
J.S.
@jspeda
you wouldn't use map in this situation
map is for when you have an array, and you want to perform some type of transformation on that array
good video^
John Nunns
@johnnunns
just watched it haha @jspeda
which higher order function would you use to solve the problem then?
J.S.
@jspeda
you can just call .length on the string
and call it a day
or wait
John Nunns
@johnnunns
nah it's way more complicated unfortunately :)
J.S.
@jspeda
what are you trying to do exactly
John Nunns
@johnnunns
count each character and separate them - example 'banana' becomes b - 1 a - 3 n - 2
var output = countAllCharacters('banana');
console.log(output); // --> {b: 1, a: 3, n: 2}
J.S.
@jspeda
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
JD Tadlock
@jdtdesigns
@jspeda You can use .map() on an object or array
@johnnunns I used .reduce() and .map()
you have my code lol
John Nunns
@johnnunns
man unfortunately I do not! closed out of chrome that day before bed and lost it :(
J.S.
@jspeda
sorry to lead you astray, I should have asked what you were doing more specifically!
John Nunns
@johnnunns
sorry bud @jdtdesigns
JD Tadlock
@jdtdesigns
Ve Vanderpool
@VanAmoVe
hey everyone! I am working on my tribute page and I am stuck! I cant figure out how to change the opacity of my background image without changing everything. Help! This is my code
body
{
background-image:url("https://static-wp.lonewolfmag.com/140717134225-frida-kahlo-photo-horizontal-large-gallery.jpg");
background-attachment:fixed;
background-size: cover;
background-repeat: no-repeat;
}
sorry didnt know it was going to post that way
JD Tadlock
@jdtdesigns
@VanAmoVe You can just set the background on a pseudo element and then lower the opacity
Sunny Wong
@swong194
@VanAmoVe try making a class and setting a opacity?
JD Tadlock
@jdtdesigns
it won't affect the text then
Ve Vanderpool
@VanAmoVe
@jdtdesigns what do you mean by a pseudo element?
i did try making a class and it just made the image go into the div and not the background
John Nunns
@johnnunns
@jdtdesigns I took out the part of the code that changes '.' and '?' and the lower case replaces
Just so I can grasp it a bit more without overcomplicating
var string = 'banana';

function countAllCharacters(str) {

    str.split('')
    str.reduce(function(result, letter) {
      var regex = new RegExp('[^' + letter + ']', 'g');
      result[letter] = string.replace(regex, '').length;

      return result;
  }, {})
}

countAllCharacters(string)
var string = 'banana';

function countAllCharacters(str) {

    return str.split('')
    .reduce(function(result, letter) {
      var regex = new RegExp('[^' + letter + ']', 'g');
      result[letter] = string.replace(regex, '').length;

      return result;
  }, {})
}

countAllCharacters(string)
ok figured out it needs to look like this
the regexp looks a bit confusing did you say I should just look up match() and replace it with that?
JD Tadlock
@jdtdesigns
@johnnunns It depends on the way you're coding it
John Nunns
@johnnunns
what's the '[^' @jdtdesigns
JD Tadlock
@jdtdesigns
The ^ matches everything except that character
Ve Vanderpool
@VanAmoVe
@jdtdesigns thank you, I think I see what your are saying brb
CamperBot
@camperbot
vanamove sends brownie points to @jdtdesigns :sparkles: :thumbsup: :sparkles:
:cookie: 877 | @jdtdesigns |http://www.freecodecamp.com/jdtdesigns
JD Tadlock
@jdtdesigns
@johnnunns
John Nunns
@johnnunns
someone in the js help spot just solved it before you logged in. While your code passes 2/3 tests, this code passes all. @jdtdesigns
function countAllCharacters(str) {
  // your code here
    var array = str.split("")
  var object = {};

  if(str.length === 0) return object;
  else{
  for(var i = 0; i < array.length; i++){
    if(object[array[i]]) object[array[i]]++;
    else object[array[i]] = 1;
  }
  return object;
  }

}

var output = countAllCharacters('banana');
console.log(output);
can you spot a difference?
JD Tadlock
@jdtdesigns
@johnnunns It's counting spaces lol
John Nunns
@johnnunns
your code is? @jdtdesigns
JD Tadlock
@jdtdesigns
nope