I want to iterate over two arrays and check if the second array has any values which match the first one. I am currently trying to do it as follows, but im sure its incorrect. How can I do it ?
changeType = (el,shapeType) ->
elTypes = ['circle','square','triangle']
elClasses = el.attr 'class'
classTypes = elClasses.split " "
for type of elTypes
for types of classTypes
el.removeClass type if classTypes[types] is elTypes[type]
el.addClass shapeType
[Edit] while structure which seems to also be incorrect
x = 0
while x <= classTypes.length
i = 0
while i <= elTypes.length
if elTypes[i] is classTypes[x]
el.removeClass elTypes[i]
i++
x++
el.addClass type
attrandremoveClasscalls suggest that you're using jQuery, is this true?whilestructure