Skip to content

Instantly share code, notes, and snippets.

@naffiq
Created October 4, 2016 10:35
Show Gist options
  • Save naffiq/878f8cad5701ce81d555f6878f5d989b to your computer and use it in GitHub Desktop.
Save naffiq/878f8cad5701ce81d555f6878f5d989b to your computer and use it in GitHub Desktop.
Telegram Math battle win code
var answer = function()
{
var calc = function(x, y, op) {
x = parseFloat(x); y = parseFloat(y);
if (op == '+') return x + y;
if (op == '–') return x - y;
if (op == '×') return x * y;
if (op == '/') return x / y;
}
var x = document.getElementById('task_x').innerHTML;
var y = document.getElementById('task_y').innerHTML;
var op = document.getElementById('task_op').innerHTML;
var res = document.getElementById('task_res').innerHTML;
var calcRes = calc(x, y, op);
console.log(x, op, y);
console.log('res', res);
console.log('calc', calcRes);
if (res == calcRes) {
document.getElementById('button_correct').click();
} else {
document.getElementById('button_wrong').click();
}
}
var i = 1;
while(i < 666) {
setTimeout(function() {answer()}, i++ * 100);
}
@romooly
Copy link

romooly commented Oct 9, 2016

how can use ?

@ismaeilmohammadi
Copy link

hey nafiq
how can i use this code?

@ismaeilmohammadi
Copy link

come on nafiq
com on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment