Word Blanks how does it work excatly?

we are asked to ;

// Your code below this line

  var result = "";

the example the gave us was

var sentence = "It was really" + "hot" + ", and we" + "laughed" + "ourselves" + "silly.";

thing i got from the challenge
we need spacing somewhere where i have no idea . and the rest was to hard to understand really
farest i got is
string concatenation operator= refering to the example of the 2nd code i have here above

var result = "myNoun" + "myAdjective" + ", myVerb" + "myAdverb" ;

and then i did’t pass
i tried looking up the answere
but so far i have still no clue what i am doing wrong can someone explain it?

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/word-blanks

1 Like

Hi there,

I’ll try to explain the best I can.

When you use “myNoun” with the quotes, you are actually using a literal string rather than a variable.

“myNoun” - a string of characters that spells myNoun (or a combination of characters “m” + “y” + “N” + “o” + “u” + “n”)

myNoun - a variable (observe the no quotes) that can contain many things. In this case, it can refer to any string you want. It can contain the string “dog”, “cat”, “human”, or anything.

In your result, try removing the quotes and you’ll get the variables.

I’m on mobile so the explanation might be unclear. Feel free to ask for clarification.

1 Like

Yes I would love a clarification onto this :3 can you make one which explains step by step? our is explained really simpely i’m really not the best at this.

1 Like

I’m sorry for the late reply.

Have you passed the challenge?

If not and if you need more help, I can try to walk you through it slowly. If you’re interested, that is.

Not yet i did try to find out more information about it but, ended up stuck again. :frowning: thanks for comming back thou.

1 Like

That’s okay. Everyone gets stuck so no need to feel bad about yourself.

I can try to explain again tomorrow, if you’re up for it?

for sure :smile: will be waiting for you tomorrow then not going to stop untile it solved. If i find a sollution in the meantime i also will let you know :3

1 Like

This challenge is using concepts not taught yet (function, parameters, and arguments). It has been fixed in the up coming version (that link will not stay up forever).

It is basically this challenge, but using a function with parameters getting passed arguments.

Let’s try with some code, see if it makes sense.

No function:

const animal = 'dog';
const sound = 'woof'

const sentence = 'My' + ' ' + animal + ' ' + 'says' + ' ' + sound;

console.log(sentence)
// My dog says woof

With function:

function MyAnimalWithSound(animal, sound) {
  const sentence = 'My ' + animal + ' says ' + sound;
  console.log(sentence)
}

MyAnimalWithSound('dog', 'woof');
// My dog says woof
2 Likes

I see that someone has given the solution.

This challenge is using concepts not taught yet (function, parameters, and arguments). It has been fixed in the up coming version (that link will not stay up forever).

I didn’t know that this was the case. Good to know.

1 Like

Dear lasjorg,
Good morning,

I appreciate and thank you for the kind orientation,
as i finished the challenge of wordBlanks i though i had success in the code, it took me hours to pass this challenge, i though the challenge was related to the practice of the use of concatenation and assigning values to a variable but i had no idea that it was related to the usage of functions and it is true that i still have some doubts about the usage of the functions, parameters, and arguments, i guess i need to read about functions, do you have some resources that you can share with me about it?
Also the webpage of freecodecamp is not actualized , do you avise to use better the upcoming version to continue with the lessons?

I thank you and appreciate for any orientation you will have, thank you again lasjorg and i wish you a lovely day,
Kind regards,

Ivonne

Sorry I didn’t see your reply to me. Use the at symbol (@userName) in front of the name or the reply button to make a reply to a post. Both will give the user a notification.

  1. You will learn about functions and parameters/arguments later in the curriculum. This challenge, in its current form (or placement) is really just a mistake. Here is some more reading material on functions.

  2. No, you should not use the preview version of the curriculum (www.freecodecamp.dev/learn/) to complete the challenges. The challenges should be done on the current version (learn.freecodecamp.org).

Did the code example I posted in this thread help? You can always post any new code and questions you have in your thread. But please post the code and not pictures. If you click the </> on the toolbar when making a post you can format the code.

Dear lasjorg,
Good afternoons,
I´m sorry for my late reply and i appreciate so much your kind help and your time.
I will read the resources you sent me, and i have a question always about the challenge of
Stand Line , why we use the vertical bars in the part of the return ?
and in which cases should we use it?
I send you here a picture of my solved challenge

Thank you again lasjorg for all your kind help, they will be very appreciated,
Kind regards,
Ivonne

I’m not getting any notifications of your response to me. So I don’t see your posts. Please use @UserName like so for your name @Ivonne, if you do that for my name I get a notification.

We use it to check if the value on the left-hand side is Truthy if it is we use that value. If it is not, we use the value on the right-hand side.

true || 'some value'
// true

false || 'some value'
// "some value"

It is/was often also used to assign default values to parameters.

function getName(name) {
  // if name is not Truthy, for example undefined, use 'default'
  const fullName = name || 'default';
  ...do something
}

Dear @lasjorg,

Thank you so much for the clear explanation :slightly_smiling_face:
i appreciate it so much, i wish you a lovely day and thank you for your kindness :slightly_smiling_face::slightly_smiling_face:
I´m very happy to understand now the usage of the vertical bars
kind regards,
Ivonne