Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Задание первой лекции #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions sort.js
Original file line number Diff line number Diff line change
@@ -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 '++'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно в начале кода добавить /*jslint plusplus: true */, чтобы jslint не ругался

for (i = 0; i <= (temp.length - 1); i++) { //Unexpected '++'
num_one = parseInt(temp[i]); //Missing radix parameter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing radix parameter - желает получить систему счисления которую будет использовать для парсинга строки. Можно просто писать + temp[i] см https://speakerdeck.com/u/azproduction/p/2-liektsiia?slide=13

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSlint не знает в какой среде используется JS поэтому ругается - можно ему намекнуть - /*jslint browser: true, devel: true */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Старайся не использовать document.write лучше уж alert() а еще лучше явно показать куда пишешь - document.body.innerHTML = temp[i];

}
}