Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 19 2020 20:09
    @krisb1220 banned @Gastony
  • May 14 2020 22:38
    @bjorno43 banned @minitechtips_twitter
  • May 14 2020 22:37
    @bjorno43 banned @real-action
  • Feb 01 2020 00:26
    @bjorno43 banned @Ndoua
  • Jan 07 2020 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • May 10 2019 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 2019 17:12
    @mstellaluna banned @cmal
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:09
    thecodingaviator commented #31179
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:07
    thecodingaviator commented #31182
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator commented #31190
  • Apr 01 2019 18:05
    thecodingaviator commented #31157
  • Apr 01 2019 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

Diego Mayer
@Chrono79
use indexOf with an array, don't use strings
Zane Hewgley
@zhewgley
@dhp1161 trial and error. Gotta learn from mistakes.
which i seem to be doing a lot haha
manugp
@manugp
Need a little help with Javascript. I wanting to try nesting functions for making the code to TitleCase a sentence. But I am getting the error "TypeError: value.shift is not a function".
The code is;

function titleCase(str) {
str = str.split(' ').map(function(value){
return value.split('').unshift(value.shift().toUpperCase).join();
}).join();
return str;
}

titleCase("I'm a little tea pot");

Diego Mayer
@Chrono79
@manugp because value isn't an array probably, yes, value is a string
manugp
@manugp
So what can I do here
Zaluth
@Zaluth
@Chrono79 i still don't get it, won't it just return the position?
Diego Mayer
@Chrono79
@Zaluth you could use that with filter, -1 it isn't there, any other value, it's there
David Amanze
@GodKingShogun
does anyone know if i can use the replace method after i use the split method
Diego Mayer
@Chrono79
@manugp use string methods
@GodKingShogun no, replace is a string method, split returns an array
manugp
@manugp
@Chrono79 How about this

function titleCase(str) {
str = str.split(' ').map(function(value){
return value.split('').unshift(value.split('').shift().toUpperCase).join();
}).join();
return str;
}

titleCase("I'm a little tea pot");

Zaluth
@Zaluth
@Chrono79 like an if else?
Diego Mayer
@Chrono79
@manugp nope, try substr, slice or substring
@Zaluth no need, return arrayToDestroy.indexOf(element)===-1 <- that keeps the elements that you shouldn't destroy
David Amanze
@GodKingShogun
@Chrono79 lets say i use the replace method and i want to replace the first letter in each word in a string can i use .toUpperCase in the replacement part of the replace method
Diego Mayer
@Chrono79
@GodKingShogun yes, you can use a function
Zaluth
@Zaluth
@Chrono79 but indexOf returns only the first occurrence
Diego Mayer
@Chrono79
you're using map @Zaluth
David Amanze
@GodKingShogun
@Chrono79 ok. how do i target the first letter in each word of a string
Diego Mayer
@Chrono79
@GodKingShogun with a regex
David Amanze
@GodKingShogun
would it be the /D
@Chrono79
Diego Mayer
@Chrono79
@GodKingShogun I don't think so
David Amanze
@GodKingShogun
@Chrono79 i dont think any of the prior lessons taught me how to target the first letter of each word
Diego Mayer
@Chrono79
@GodKingShogun That's why you should stick with string index and simple functions like slice (at least for the time being)
It can be done with a regex, but in FCC there are no lessons about it
David Amanze
@GodKingShogun
@Chrono79 i don't think the prior lessons have taught me string index or slice to lol
too*
David Amanze
@GodKingShogun
@Chrono79 oh yea i remember that lesson. it's been a while
lol
Zaluth
@Zaluth
@Chrono79 i'm still so lost
function destroyer(arr) {
  var args = [].slice.call(arguments);
  var slice = args.slice(1);

  // slice = [2,3]
  // arr = [1, 2, 3, 1, 2, 3]
  // args = [[1, 2, 3, 1, 2, 3], 2, 3]

  function filter(value) {
    return value === slice;
  }

  var seek = arr.filter(filter);
  return seek.indexOf(slice) === -1;

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3, 4);
Diego Mayer
@Chrono79
@Zaluth the indexOf goes inside your filter function
David Amanze
@GodKingShogun
@Chrono79 i reviewed both materials but still not sure how i can target each first letter of words in a string. basically if the argument is"red is my favorite color" the function would have to return "Red Is My Favorite Color"
Diego Mayer
@Chrono79
@GodKingShogun you could use split(" "), to get an array of words, change each word, and then use join(" ") to get a string back
David Amanze
@GodKingShogun
@Chrono79 but i thought you said i couldnt use the replace method after the split method
Greg Duncan
@GregatGit
@Zaluth first create an array of elements that will purge
Diego Mayer
@Chrono79
@GodKingShogun no, you could use replace with a regex (and we discarded that path because it requires knowing how to use it)
Greg Duncan
@GregatGit
@Zaluth you should write a function with a different name that filter but uses indexOf()
@Zaluth then using filter use your new fitlter function to create the a new array and return that array
David Amanze
@GodKingShogun
@Chrono79 i know how to use regex a little. im just not sure which regexp i would use to target the first letter of each word
Diego Mayer
@Chrono79
@GodKingShogun it's not an easy one to figure out
Anshul Bisht
@chocochip15
can anybody help me out wid counting cards problem in java script ??
Diego Mayer
@Chrono79
@chocochip15 show your code
David Amanze
@GodKingShogun
i said /D earlier because /d targets digits and the opposite of any regexp is capitalized
Diego Mayer
@Chrono79

@GodKingShogun let's go with this path:

@GodKingShogun you could use split(" "), to get an array of words, change each word, and then use join(" ") to get a string back