Do you know how I can take, for example, the last 2 characters of a string.
So if I have 2004 it will convert it to 04.
Like replace, but not!
thanks
Bernard Marx
4:48 pm on Jun 23, 2004 (gmt 0)
var str="hello" alert(last(str,2)) // takes number or string // returns string function lastChars(inp,n) { inp = ""+inp // so it handles numbers too return inp.substring(inp.length-n) }