From 51301fc2e335177d2fcb68b9ddb02eed6768a81c Mon Sep 17 00:00:00 2001 From: Emilya Date: Fri, 12 Oct 2012 23:33:00 +0500 Subject: [PATCH 1/2] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=B9=20=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Исправила код с помощью http://jslint.com/. Возникло несколько трудностей, с которыми я не смогла справиться. Посмотрите, пожалуйста. --- sort.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 sort.js diff --git a/sort.js b/sort.js new file mode 100644 index 0000000..64ba937 --- /dev/null +++ b/sort.js @@ -0,0 +1,31 @@ +function showElem() { + "use strict"; + var myform, + vseg = myform.elements[0].value, + mass = [], + temp = vseg.split(' '), + j = 0, + i = 0, + num_one, + num_two, + max; + for (j = 0; j <= (temp.length - 1); j++) { //Unexpected '++' + for (i = 0; i <= (temp.length - 1); i++) { //Unexpected '++' + num_one = parseInt(temp[i]); //Missing radix parameter. + num_two = parseInt(temp[i + 1]); //Missing radix parameter. + if (num_one <= num_two) { + max = num_two; + temp[i] = num_one; + temp[i + 1] = max; + } + if (num_one > num_two) { + max = num_one; + temp[i] = num_two; + temp[i + 1] = max; + } + } + } + for (i = 0; i <= (temp.length - 1); i++) { //Unexpected '++' + document.writeln(temp[i]); //'document' was used before it was defined. document.write can be a form of eval + } +} \ No newline at end of file From 74bd2f1315a4e7e818e8530db6135d40d761631a Mon Sep 17 00:00:00 2001 From: Emilya Date: Sun, 14 Oct 2012 11:30:34 +0500 Subject: [PATCH 2/2] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=E2=84=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sort.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sort.js b/sort.js index 64ba937..b23ba19 100644 --- a/sort.js +++ b/sort.js @@ -1,3 +1,5 @@ +/*jslint plusplus: true */ +/*jslint browser: true, devel: true */ function showElem() { "use strict"; var myform, @@ -9,10 +11,10 @@ function showElem() { num_one, num_two, max; - for (j = 0; j <= (temp.length - 1); j++) { //Unexpected '++' - for (i = 0; i <= (temp.length - 1); i++) { //Unexpected '++' - num_one = parseInt(temp[i]); //Missing radix parameter. - num_two = parseInt(temp[i + 1]); //Missing radix parameter. + for (j = 0; j <= (temp.length - 1); j++) { + for (i = 0; i <= (temp.length - 1); i++) { + num_one = +temp[i]; + num_two = +temp[i + 1]; if (num_one <= num_two) { max = num_two; temp[i] = num_one; @@ -25,7 +27,7 @@ function showElem() { } } } - for (i = 0; i <= (temp.length - 1); i++) { //Unexpected '++' - document.writeln(temp[i]); //'document' was used before it was defined. document.write can be a form of eval + for (i = 0; i <= (temp.length - 1); i++) { + document.body.innerHTML = temp[i]; } } \ No newline at end of file