Lodash words( )

Hello,

I’ve been stuck on this lodash project and because there are no hints it can be frustrating when stuck.

I’ve looked and searched but I’m stuck.
I feel the solution is simple but I’m also tired and been looking at this screen way too long.

Lodash question 13:

I’m stuck:

words(‘This is a test’) {
const words = ;
return words;
},

Above is all I have but 13 is specifically stumping me at the moment.

https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash

Thank you,

1 Like

What’s stopping you?
Have you gotten an understanding of how your function should behave?
Have you thought about what actions you need to describe that behaviour?
The code you posted isn’t valid syntax, perhaps you might start out by writing a function that doesn’t do anything but at least runs without crashing? If you’re struggling with syntax then you should probably go look at that before doing anything else.

1 Like

I understand that the function should split the words from the string into an array.

What’s stopping me specifically was:

  1. Within the method, create a variable called words and set its value equal to string split on space characters ' ' using the .split() method.

I was simply following the instructions like the other 2 previous examples (inRange and clamp) in the project.

I added the method "words’ to my _ object:

words( ) {
},

It then asks to ad a parameter “string”, so I took that as adding any string as a parameter.

I was following similar syntax as clamp and inRange because when testing those methods, they were successful:

const _ = {
clamp(number, lower, upper) {
const lowerClampedValue = Math.max(number, lower);
const clampedValue = Math.min(lowerClampedValue, upper);
return clampedValue;
},

inRange(number, start, end) {
if (end === undefined) {
end = start;
start = 0;
};

if (start > end ) {                          
  const temp = end;
  end = start; 
  start = temp;
};

const isInRange = start <= number && number < end;

return isInRange;

},

words(‘This is a test’) {
const words = ;
return words;
},

};

I’ll definitely go back and look at the syntax and what I’m doing wrong.

Thank you for the response.

1 Like

Why does that stop you? Do you know how string’s split method behaves? If not, that is something you can look up.

You can’t put the input to a function in a function definition, that’s not how functions work, the point of functions is to provide input at a later time.

1 Like