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
Stephen James
@sjames1958gm
@zifahm great, I make that mistake alot
Muhammed Hafiz
@zifahm
@sjames1958gm i am stuck here currently
https://beta.freecodecamp.org/en/challenges/react-and-redux/extract-state-logic-to-redux
const ADD = 'ADD';

const addMessage = (data) => {
  return {
    type:"ADD"
    message:data
  }
}


const messageReducer = (state=[],action) => {
  switch(action.type) {
    case 'ADD':
      return Object.assign({},state,{
        message:action.message
      })
      default:
      return state
  }
}

var store = Redux.createStore(messageReducer)
console says unexpected token near message in action creator
Stephen James
@sjames1958gm
@zifahm Missing comma after "ADD" (also you are supposed to use the variable ADD in place of the string)
Muhammed Hafiz
@zifahm
@sjames1958gm lol
half an hour on this
ahh now the immutable error !!
Dispatching addMessage against the store should immutably add a new message to the array of messages held in state.
wouldn't my reducer work?
Stephen James
@sjames1958gm
@zifahm array of messages
Muhammed Hafiz
@zifahm
got it!
Stephen James
@sjames1958gm
@zifahm :+1:
Muhammed Hafiz
@zifahm
return [...state,array.message]
so the thing i did before what did happen there in the state ? @sjames1958gm
Stephen James
@sjames1958gm
@zifahm well I am thinking you converted state from an array to an object containing an array called state with a extra value called message
{ state: arrayfrombefore, message: newmessage}
Muhammed Hafiz
@zifahm
ohh yeah object !!
getting confused with this and that
:worried:
Stephen James
@sjames1958gm
@zifahm Keep working at it the confusion will lessen (it never completely goes away :) )
Muhammed Hafiz
@zifahm
@sjames1958gm thanks
dinesh
@1532j0004kg
cool & happie evening friends ! :smile:
Stephen James
@sjames1958gm
@1532j0004kg Morning
dinesh
@1532j0004kg
morning there ? :+1:
happie
Stephen James
@sjames1958gm
@1532j0004kg Yep, and a cold one -6 C
dinesh
@1532j0004kg
enjoy :smile:
england ?
Stephen James
@sjames1958gm
Texas
amoraptor91
@amoraptor91
good morning campers
Amit Patel
@AmitP88

hey guys, I'm trying to solve the Title Case A Sentence algorithm and I'm having trouble figuring out why my solution isn't working:

function titleCase(str) {

  var wordsArray = str.split(' ');

  var capitalized = wordsArray.map(function(word) {

    var capWord = word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();

    var newString = capWord.join(" ");

    return newString;

  });



  return capitalized;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");

I know my capWord.join method isn't working, but I'm not sure why. What am I doing wrong?

Aditya
@ezioda004
@AmitP88 capWord is a string and .join() is an array method.
Amit Patel
@AmitP88
@ezioda004 but capWord is an array of strings no?
title.png
@ezioda004 the weird thing as well is, when I console.log(capWord), I get an array of null elements in the console
Aditya
@ezioda004
@AmitP88 Nope, capitalized is an array. word is an element of wordsArray array.
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); you're concatenating 2 strings
Therefore youre storing a string in var capWord
Amit Patel
@AmitP88
oh I see. so I would have to make another function to pass in capitalized as a parameter?
another function to do the joining
Markus Kiili
@Masd925
@AmitP88 The only thing you need to join is capitalized.
Amit Patel
@AmitP88
@Masd925 hmmm, ok, let me try it real quick
Markus Kiili
@Masd925
From the callback function you need to return the capitalized word (made from the original stored in parameter word).
@AmitP88
Aditya
@ezioda004
@AmitP88 You just need to return capWord in the map. If you console.log(capitalized)now you'll see its an array so just join() it and return.
Amit Patel
@AmitP88
@ezioda004 it worked :)

function titleCase(str) {

  var wordsArray = str.split(' ');

  var capitalized = wordsArray.map(function(word) {

    var capWord = word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();

    return capWord;

  });

  console.log(capitalized);

  return capitalized.join(" ");
}





titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
damn, I can't believe I got stumped on such a small detail like that lol
Aditya
@ezioda004
@AmitP88 :thumbsup: It happens, you'll remember that detail now :D
Gersho
@Gersho
really ? i usually have to do the same mistake 10 times before i remember it :P
Markus Kiili
@Masd925
@AmitP88 You could try removing some of those variables that you declare there. Might also get more readable that way.
Amit Patel
@AmitP88
lol thanks @ezioda004 :)