How can I add toUpperCase function in 1 line for these 2 variable together?

Please post your actual code instead of a picture of code. Thanks.

I don’t understand your question. Can you please explain what you are asking?

1 Like

You can add the two strings, store them to a variable than .toUpperCase that variable in one line.(don’t forget to add spacing when adding the 2 strings).

1 Like

Hey @abdullahbinziad , ^-^

If all you are trying to do is grab two strings, concat them and convert them to upperase, the shortest Lines Of Code would be:

let text = "hello";
let text2 = "world";

let final = (text+" "+ text2).toUpperCase()
console.log(final) // HELLO WORLD

// concat the two strings and call toUpperCase() on them after concat
// the blank space concat in between text1 and text2 is just to give some space to the resulting text
//otherwise they would look congested like HELLOWORLD, without the blankspace

OR w/ the concat method

let final = (text.concat(" ", text2)).toUpperCase();
console.log(final) // HELLO WORLD
// again the " " is just to put some space between HELLO and WORLD

Happy Coding

1 Like

Thank you so much Brother :heart_eyes:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.