Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Why this function doesn’t work in ‘for loop’ ? [jquery] Re: Why this function doesn’t work in ‘for loop’ ? [jquery]

#127662
pixelgrid
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