Need help solving this problem

Joined
May 9, 2023
Messages
1
Reaction score
0
Linda's farm has had a very bountiful harvest!

She needs to sell her produce as soon as possible whilst it is still fresh. Luckily your new JavaScript skills using operators, properties and methods to form expressions are just the tools needed to take advantage of this time of plenty!

To solve the challenge:

  • Create a new variable twiceTheCarrots. Assign to it a value equal to double the value of carrots.
  • Create a new variable characterCount that will store the length of the text on the board.
  • Create a variable called shoutingText and assign it text of the board, but with all characters as capital letters.

function lindasBounty() {
const carrots = 239;
const boardText = 'Buy our carrots! Sale Now On!';
// Do not change code above this line
// Do not change code below this line
return {
const twiceTheCarrots=
const characterCount= boardText.length
const shoutingText= boardText.toUpperCase()
};
}
 
Joined
Mar 31, 2023
Messages
95
Reaction score
8
Here's a corrected version of the code:

function lindasBounty() {
const carrots = 239;
const boardText = 'Buy our carrots! Sale Now On!';
// Do not change code above this line
// Do not change code below this line
const twiceTheCarrots = carrots * 2;
const characterCount = boardText.length;
const shoutingText = boardText.toUpperCase();
return {
twiceTheCarrots,
characterCount,
shoutingText
};
}

In this code, we first declare and initialize two variables carrots and boardText. We are then asked to create three new variables: twiceTheCarrots, characterCount, and shoutingText.

We create twiceTheCarrots by multiplying carrots by 2.

To find the length of boardText, we use the length property of the string, and assign it to characterCount.

Finally, we create shoutingText by calling the toUpperCase method on boardText, which returns a new string with all the characters in uppercase.

Note that we use object shorthand notation to create the object that is returned by the function, so we don't need to repeat the variable names in the object literal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top