Codecademy Forums

Count words

Hello,
I’m a beginner in JavaScript.
I’m looking for how to count the words of a sentence.
It’s to practice, not for a project !
This is an attempt to practice Codecademy’s courses : :slightly_smiling_face:
Thanks to give me a hint or explain to me what I forgot !

let myMonkey1 = ’ do not see anything’;
var myMonkey2 = ’ not hear anything’;
const myMonkey3 = ’ say nothing’;
let domiSays = ’ Hey, U ! Do you code as well ? :)’
console.log(‘The motto of the three monkeys is’ + myMonkey1 + ‘,’ + myMonkey2 + ‘,’ + myMonkey3 + ’ !’+ domiSays);

const str = myMonkey1 + myMonkey2 + myMonkey3 + domiSays;
console.log(str.lengt);
//output : undifined !
Domi Martin :wink:

1 Like

Looks like just a simple spelling mistake :wink:

3 Likes

Thank you for your reply !
Sorry to have created a topic for that !
I’m just giddy !
So, I tested and could check my code by adding :
Have a nice day ! :wink:

console.log(str.length); //84
console.log('The value of str: ', str);
/The value of str: do not see anything not hear anything say nothing Hey, U ! Do you code as well ? :slight_smile:/

2 Likes