Function rant issues

Hello. I’m working on a function exercise and wanted to know what I was missing.

I appreciate help

It is easier to help with your actual code instead of pictures. Thanks.

You can’t your message to uppercase like that. I would double check how toUpperCase() works in the MDN documentation.

Also, I would double check the MDN documentation on console.log().

2 Likes

Hello. I was looking for some help on why this piece of code isn’t printing properly. Please take a look and help me.

Thanks!

First of all, please don’t post pictures of code - cut and paste the code.

Anyway, it says to print out an uppercase version of the parameter message, not “rant”.

It also says to do it 3 times - you only do it once.

You gave “3” as the second parameter to console.log - that is not some kind of multiplier. You are telling it to print “RANT 3”.

1 Like

Here is how to write code in the forum

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

It is also telling you “with 3 separate calls to console.log” so even if that was a feature of console.log it would likely still fail. Same if you used a loop I’m guessing.

Inside the function call console.log() three times in a row. Pass each call the message parameter and use .toUpperCase() on it.

OK, this is slightly different code than what you had in the other thread where I’d answered (that got copied here).

Now you have console.log("message", 3). The “,3” has already been explained, but you’ve wrapped message in quotes, telling it that it not the parameter your function received, but a string literal saying “message”. That isn’t what you want.

I will try that thank you.

Okay, lol. So then what do I want?

What have you tried make multiple console.log()s? Other than this ,3 thing, which isn’t in the documentation:

Call console.log() 3 times inside the function and pass each of them message.toUpperCase().

Example code:

function jollyGoodFellow(lyrics) {
  console.log(lyrics.toUpperCase()); // FOR HE'S A JOLLY GOOD FELLOW 
  console.log(lyrics.toUpperCase()); // FOR HE'S A JOLLY GOOD FELLOW 
  console.log(lyrics.toUpperCase()); // FOR HE'S A JOLLY GOOD FELLOW 
}

jollyGoodFellow("For He's a Jolly Good Fellow");

AHh so I wanted the uppperCase inside the printing/console logs. I need to get used to that. Thank you.

Yes, even though it might look like console.log returns a string it actually returns the value undefined and you can’t call .toUpperCase() on that. It prints the argument to the console but it doesn’t return it.

function fakeLog(message) {
  return message;
}

function useFakeLog(lyrics) {
  return fakeLog(lyrics).toUpperCase();
}

console.log(useFakeLog("Some message")); // SOME MESSAGE

When I’m in doubt, I use MDN.

toUpperCase() creates a brand new string rather than modifying the original, so you need to design your code to accommodate this behavior.

First of all, I screen cap and post the picture because its easier to just post the full exercise explanation. I’m not typing all of that dude lol.

So you want us to help you but you aren’t willing to do a basic level of effort to help us help you more easily? That is not a very kind attitude to take towards strangers that are offering to help you for free!

My eyes aren’t great. You taking a few seconds to copy-paste the code and directions instead of using a screenshot helps me offer you my $50/hr skills for free! Please be kind to people who you are asking for help from. Thank you!

4 Likes

First of all isn’t a “first of all” supposed to be followed up by another statement?
Then please use a more respectful tone to people who try to help you.
Finally, you do know you can copy-paste text? Yeah it might be not the easiest thing in the world, but you cannot expect programming to be a cakewalk. If you lack the motivation to properly ask for help, you will run into issues later because if you are not willing to work on decent questions, why should others be willing to work on the answers?

1 Like

All fair, but I can’t copy and paste for some reason from Udemy’s page. Try yourself if you want, that’s the full truth. Maybe its so we don’t “cheat” but that’s the truth. Sorry if I was being harsh.

Apologies, its been a bitch of a morning so far. At this point, here is my frustration using help.

  1. Too many people are giving me advice and its honestly a little confusing given the way I’m learning to code.
  2. I have pretty bad ADHD and although it isn’t an excuse, I’d rather get clear coding assistance from one or two people on
    a given topic etc.
  3. I’ve been able to complete most of the given exercises in this online bootcamp and as a result, things have been moving very smoothly in understanding what the code is doing and why. Which is great. However, in the last week or so, I’ve been falling behind on my exercises and they’re beginning to pile up making my feel behind and like I’m not understanding what I learned before etc.

Again I appreciate the help and most of what has been said here has been useful to me, however lately the advice and work has just been piling up and I had a good daily “flow” going on.