How to make string letters uppercase? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

How to make string letters uppercase?

Hi guys.How can i write a function that access the first and last letter of a string in an object and make the 2 letters uppercase

8th Mar 2021, 7:38 PM
CedyAdvance
10 Antworten
+ 3
Cedrich See your mistakes. I have resolved. https://code.sololearn.com/Wdpm7bFowXLx/?ref=app
8th Mar 2021, 8:15 PM
A͢J
A͢J - avatar
+ 3
function upperCase(str) { var last = str.length-1; console.log(str[0].toUpperCase()+str.slice(1,last)+str[last].toUpperCase()); } upperCase("cedrich");
8th Mar 2021, 8:10 PM
visph
visph - avatar
+ 1
Can you please give one example and also post your try too
8th Mar 2021, 7:43 PM
Atul [Inactive]
0
you must get the first and last char, turn them uppercase, then return concatenation of first (upper) char + 2nd to last-1 chars + last (upper) char... you must also try by yourself first, then request for help if needed... do kot forget to provide link to your code attempt ^^
8th Mar 2021, 7:43 PM
visph
visph - avatar
0
There is my code ande its returning NaN.....https://code.sololearn.com/WHcdb0nTpgm6/?ref=app
8th Mar 2021, 8:05 PM
CedyAdvance
0
Thanks I Am AJ ! for the help ,i noticed what i was doing wrong.i appreciate the correction
8th Mar 2021, 8:24 PM
CedyAdvance
0
Thanks visph for the help,thats another way of solving it that i had not thought about.
8th Mar 2021, 8:28 PM
CedyAdvance
10th Mar 2021, 12:43 PM
Sanjay Kamath
Sanjay Kamath - avatar
- 1
I have edited the parameters but its still returning NaN
8th Mar 2021, 8:15 PM
CedyAdvance
9th Mar 2021, 7:06 AM
Ryan Els
Ryan Els - avatar