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
I changed it back to str.split('') forgot to change before i copy pasted
Tyler Moeller
@TylerMoeller
But yes, your switch statement runs once against the array
John Nunns
@johnnunns
yeah ^ :)
Tyler Moeller
@TylerMoeller
For example, say str='hello world';
You are doing:
  switch (['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']){
  case 'a': sum + 1;
  break;
  case 'e': sum + 1;
  break;
  case 'i': sum + 1;
  break;
  case 'o': sum + 1;
  break;
  case 'u': sum + 1;
  break;
};
If you don't want to use higher order functions, you can use a simple for() loop and evaluate each element returned from str.split('')
John Nunns
@johnnunns
right
because case 'a' doesn't equal hello world split up
Tyler Moeller
@TylerMoeller
Long story short - don't use a switch
There are lots of options though and you could make it work with a switch statement if you have to, I just think it would be cleaner with a simple if it's a vowel, add 1 statement.
John Nunns
@johnnunns
function getCount(str) {
var sum=0
var i = str.split('');
for(var x=i; x<str.length; x++){


return sum

}
I'm just not sure how to say if one of those vowels inside the string equals a vowel
Tyler Moeller
@TylerMoeller
Start by trying to console.log each letter individually
Your for() loop needs to start at 0, then go to index 1, 2, 3 etc.
John Nunns
@johnnunns
how will I tie it into the split then if i don't set something equal to i?
Tyler Moeller
@TylerMoeller
You'll start at 0 and end when it's less than str.split('').length
Don't know how much of a hint you're looking for here ^^ that may be too much
John Nunns
@johnnunns
right, so then I can just put i.length
Tyler Moeller
@TylerMoeller
Correct
John Nunns
@johnnunns
now nest an if statement inside the for?
Tyler Moeller
@TylerMoeller
Yes, test if it's a vowel, if so, add 1 to sum
John Nunns
@johnnunns
still seems I'll run into the same problem as my switch
Salomon
@zarruk
Does anybody know how to put the transcurrido div justified in the center (instead of starting all the way from the center to the left)? I mean, if not with justify-content: center, then how? http://codepen.io/zarruk/pen/VPWrWL?editors=1100
John Nunns
@johnnunns
actually. let me try
Salomon
@zarruk
Also, why is my stop button on top of the start one? Does anybody know how to put the transcurrido div justified in the center (instead of starting all the way from the center to the left)? I mean, if not with justify-content: center, then how? http://codepen.io/zarruk/pen/VPWrWL?editors=1100
Tyler Moeller
@TylerMoeller
Try to get it to console.log() each letter in the string first.
brb
John Nunns
@johnnunns
like a console.log(i[0])?
Tyler Moeller
@TylerMoeller
Yes
That's just my approach though - make sure the for loop is working as intended before adding logic
John Nunns
@johnnunns
for loop is working good right now
where I'm running a blank though
I could write a lot of code right now but I'll ask before it doesn't work
an if statement like
if(i = "a") sum+1 ..... etc
Tyler Moeller
@TylerMoeller
A regular expression would be a little cleaner looking
John Nunns
@johnnunns
I'll show you what I have
function getCount(str) {
var sum=0
var i = str.split('');
for(var x=0; x<i.length; x++){
if (i === 'a' || 'e' || 'i' || 'o' || 'u'){
return sum + 1;
};
};

return sum

}
I'm sure you see what I'm trying to do, I see why it's only returning 1 because the loop is completed
I'm just not sure how to rework it
Tyler Moeller
@TylerMoeller
In your for() loop, what does i equal?
John Nunns
@johnnunns
str.split
Tyler Moeller
@TylerMoeller
Right, you want to compare against i[0], i1, i[2], etc..
Also, you will have to do if (i === 'a' || i === 'e' || etc...
John Nunns
@johnnunns
seems like an absolute ton of code :)
because I'm not using higher level function I'm presuming
but ok
Tyler Moeller
@TylerMoeller
The next problem is that return will stop the for loop - so you just want to add, not return inside the loop
Yes, and not using a regex :)
Melissa Guerrero
@Mmgfrog
Good evening. I am desperately seeking ideas as to why my Tweet This Quote button won't capture or tweet a quote from my Random Quote Machine. I have read the Twitter docs at length. I have tried Stack Overflow. I have asked at a Meetup. I'm out of ideas to try to get it to work. http://codepen.io/Mmgfrog/pen/egOxwq?editors=1010#0