-1

im attempting to update the first letter of a string to upper case, Please note that im only allowed to use .substr and .length to convert it. no regex or anything.

is this the right method/syntax to do so?

e1 = prompt("Please enter your first name", "andrew");

e1.toUpperCase(e1.substr(e1.length - e1.length,0));
Andrew Barsoom
  • 81
  • 1
  • 3
  • 7

1 Answers1

0

Regex everything!

e1 = prompt("Please enter your first name", "andrew");
e1.replace(/^\w/, function(t){ return t.toUpperCase() })
KJ Price
  • 5,774
  • 3
  • 21
  • 34