Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Insert a character into a string

    Suppose I have the string 'ello'.
    I want to insert the letter 'h' in the beginning of that string.

    How do I do that without using a special function? I can only use the functions charAt and indexOf - anyone has any idea?
    Last edited by jamesab1156; 04-10-2011 at 01:08 PM.

  • #2
    New Coder
    Join Date
    Apr 2011
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jamesab1156 View Post
    Suppose I have the string 'ello'.
    I want to insert the letter 'h' in the beginning of that string.

    How do I do that without using a special function? I can only use the functions charAt and indexOf - anyone has any idea?
    I got it

    Just use the + sign, stupid me... lol...

    newString = 'h' + 'ello';

    And that's it ...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •