I'm not sure if this is a stupid question but can I write something that returns a substring without using substrings?
for e.g. usually you'd write something like this:
var str = "Hello world";
var res = str.substring(1, 4);
Can i use a loop instead to do it? Or is that not possible? How would i start to do it? I know it's something to do with arrays.
would it be something like A[i] and adding loops?
+=for concatenation...Try this:var str = "Hello world"; var op = ''; for (var i = 1; i < 4; i++) { op += str[i]; } alert(op); var res = str.substring(1, 4); alert(res);var str = "Hello world"can be treated as an array. So, if you runstr[0]you will get"H".