Home › Forums › JavaScript › Why this function doesn’t work in ‘for loop’ ? [jquery] › Re: Why this function doesn’t work in ‘for loop’ ? [jquery]
March 10, 2013 at 9:52 am
#127662
Participant
the .match() returns an array so to access the number we have to
target it with brackets [] our match is the first so [0];
with the + in the regular expression we are targeting all the numbers at the end of the string .the /d$/ on input45 would return 5.
the + before num is typecasting for int in javascript.
with num = 1;
num+1 would return 11 as a string
+num+1 would return the number 2