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
function getCount(str) {
var sum=0
var i = str.split('');
for(var x=0; x<i.length; x++){
if (i[0] === 'a'){
sum + 1;
} else if (i[3] === 'a'){
sum+1;
} else if (i[5] === 'a') {
sum + 1;
} else if (i[7] === 'a') {
sum + 1;
} else if (i[10] === 'a') { 
sum + 1;

};

};

return sum;

}
still returning zero though
Tyler Moeller
@TylerMoeller
@Mmgfrog Good luck - also, you will need to update your URL to use the web intent without the widget code:
https://twitter.com/intent/tweet?text=The text you want to tweet
Melissa Guerrero
@Mmgfrog
@rfried99 Is the image you're trying to render in your header? Or is it supposed to be in some other part of the page?
Tyler Moeller
@TylerMoeller
@johnnunns You'll need to add 1 to the existing sum variable: sum++ or sum = sum + 1
Melissa Guerrero
@Mmgfrog
@TylerMoeller OK. That line looks familiar. Pretty sure I read through that in the docs. LOL
John Nunns
@johnnunns
did the sum += 1
returned 11 :)
Tyler Moeller
@TylerMoeller
:)
Now to clean it up
At least you're adding to the original now
John Nunns
@johnnunns
Well shoot, it's not only testing me on abracadabra haha
first lets clean it up though, why would it return 11?
Ronit
@rfried99
@Mmgfrog thank you! It's supposed to be in the main
CamperBot
@camperbot
rfried99 sends brownie points to @mmgfrog :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @mmgfrog |http://www.freecodecamp.com/mmgfrog
Matt Kieffer
@luna9
Ronit// take a look at your CSS / main / you are linking to a local asset. Try pushing it up and use http
Tyler Moeller
@TylerMoeller
@johnnunns it gives 11 because it's looping through the array once for each letter in abracadabra and adding 1 every time because if (i[0] === 'a') is true every time
John Nunns
@johnnunns
how do we stop that?
Tyler Moeller
@TylerMoeller
You were closer before with your previous if(), but you need to be using i[x] instead: if (i[x] === 'a' || i[x] === 'e' || i[x] === 'i' || i[x] === 'o' || i[x] === 'u') {
I could have been clearer here: :point_up: January 23, 2017 5:23 PM
Ronit
@rfried99
@luna9 I feel silly for asking this, but what do you mean by "pushing it up"
John Nunns
@johnnunns
haha you don't want to see what I've just coded. The worst code ever I typed if ( i[0] === a i[0] === e etc all the way to i[10] so far
Tyler Moeller
@TylerMoeller
lol, yeah, no need for that when you have x incrementing for you
Matt Kieffer
@luna9
Look at the source for the CSS / header - you are linking to a hosted image, http. Not look at the image you are linking to in the CSS / main. It does not have http it has file / bla / bla .
Tyler Moeller
@TylerMoeller
Keep in mind though, that's only looking at lower-case vowels
John Nunns
@johnnunns

@TylerMoeller function getCount(str) {
var sum=0
var i = str.split('');
for(var x=0; x<i.length; x++){
if (i[x] === 'a' || i[x] === 'e' || i[x] === 'i' || i[x] === 'o' || i[x] === 'u'){
sum ++;
};

};

return sum;

}

function getCount(str) {
var sum=0
var i = str.split('');
for(var x=0; x<i.length; x++){
if (i[x] === 'a' || i[x] === 'e' || i[x] === 'i' || i[x] === 'o' || i[x] === 'u'){
sum ++;
};

};

return sum;

}
that worked
Tyler Moeller
@TylerMoeller
:+1:
For lower-case vowels :)
John Nunns
@johnnunns
could have have put str.tolowercase()?
could I*
Tyler Moeller
@TylerMoeller
yes, that works
Much better than more IFs
John Nunns
@johnnunns
haha yes
is that the correct syntax?
Tyler Moeller
@TylerMoeller
str.toLowerCase()
John Nunns
@johnnunns
str.toLowerCase()
ok, just making sure nothing inside ()
Tyler Moeller
@TylerMoeller
Correct
John Nunns
@johnnunns
function getCount(str) {
  return (str.match(/[aeiou]/ig)||[]).length;
}
that was the highest rated one btw
do you know what the ig mean?
Tyler Moeller
@TylerMoeller

This was my version:

function getCount(str) {
  var vowelCount = 0;
  str.split('').map(val => {if (val.match(/[aeiou]/i)) vowelCount++});
  return vowelCount;
}

I like the one you gave better

Matt Kieffer
@luna9
@ronit looks like you just added http in from of that image link. That will not work. For testing, copy the same image URL that you are using in CSS / header and paste it in the CSS / main. This was you can see the image work. Then upload the image you want and link it.
Tyler Moeller
@TylerMoeller
@johnnunns the ig means ignore case and evaluate all characters in the string (g = global)
Ronit
@rfried99
@luna9 thx!
CamperBot
@camperbot
rfried99 sends brownie points to @luna9 :sparkles: :thumbsup: :sparkles:
:cookie: 119 | @luna9 |http://www.freecodecamp.com/luna9