-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse.js
41 lines (36 loc) · 927 Bytes
/
reverse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function reversed(input_string){
var reversed = "";
if (input_string === "") return input_string;
for(var i = input_string.length - 1; i >= 0; --i)
{
reversed = reversed + input_string[i];
}
return reversed
};
$(document).ready(function() {
var input_string = "";
$.ajax({
method: "post",
url: "http://challenge.code2040.org/api/reverse",
contentType: "application/json",
data: JSON.stringify({
token: "9bda8ddfccaecd94037ff799077d4870"
}),
success: function(data){
input_string = data;
$.ajax({
method: "post",
contentType: "application/json",
url: "http://challenge.code2040.org/api/reverse/validate",
dataType: 'json',
data: JSON.stringify({
token: "9bda8ddfccaecd94037ff799077d4870",
string: reversed(input_string)
})
});
},
error: function(data) {
console.log(data);
}
});
});