I'm taking random values from array A and B and trying to compare their solved values, is not working because values in arrays are strings, how to get them to number and solve them?
.controller('questions', function($scope) { var A = ['6-2', '7+3', '8*1', '9/3', '8+1']; var B = ['1+5', '7-3', '10-5', '10/2', '3*2']; var questionA = A[Math.floor(Math.random() * A.length)]; var questionB = B[Math.floor(Math.random() * B.length)]; if (questionA > questionB) { console.log('It\'s bigger '); } else { console.log('It\'s smaller'); } });
'7+3'to magically be10?