-2

I'd like to ask how to do only one solo from a string (JavaScript). Example: from "Hello, how are you?" a "Hello, comestai?" and therefore, therefore, count the "spaces".

YakovL
  • 7,557
  • 12
  • 62
  • 102
  • 9
    ...you haven't (explained yourself) – mayersdesign Jul 04 '18 at 19:36
  • The body of your question is confusing, but based on your title I think this is what you're looking for. https://stackoverflow.com/questions/881085/count-the-number-of-occurrences-of-a-character-in-a-string-in-javascript – Keno Jul 04 '18 at 19:37
  • 1
    Also doesn't appear that any research effort has been done on this. See [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – charlietfl Jul 04 '18 at 19:42
  • Hello Simone, welcome to StackOverflow. Your question is not clear unfortunately; I've removed the unnecessary bits from but you still have to clarify yourself (use the "edit" button). Is this really related to documents? If not, please remove the tag, if yes, please explain how. Both phrases of your question are unclear: what is "do only one solo from a string"? In the example, please explain which is an input, what's the desired output and how one should come from the other. Best regards – YakovL Jul 05 '18 at 00:08

1 Answers1

0

If you want to count the spaces in your string, i would suggest doing:

var my_string = "Hello, how are you?";
var spaceCount = (my_string.split(" ").length - 1);
console.log(spaceCount)

I hope this is what you wanted to know but i'm not sure because your question is a bit hard to identify.

Just as a side note, the function:

console.log(spaceCount)

will dump the value of spaceCount into the console log, which will display at the bottom of the code snippet

Ryan B
  • 108
  • 1
  • 1
  • 13