Reputation: 707
I created the following isqrt function.
function isqrt(n) {
var shift, result, candidateResult;
if (n < 0) {
return false;
}
for (shift = 2; n >> shift; shift += 2) {}
for (result = 0, shift -= 2; shift >= 0; shift -= 2) {
result = result << 1;
candidateResult = result + 1;
if (candidateResult * candidateResult <= n >> shift) {
result = candidateResult;
}
}
return result;
}
There is an empty block here.
for (shift = 2; n >> shift; shift += 2) {}
But this is intentional. I know I can improve this code as follows.
shift = 2;
while (n >> shift) {
shift += 2;
}
But I don`t want it.
I`m using the latest version of bracket on Windows 10. :)
Upvotes: 1
Views: 1366
Reputation: 1911
You can also do something like
/*jslint ignore:start**/
for (shift = 2; n >> shift; shift += 2) {}
/*jslint ignore:end**/
Upvotes: 1
Reputation: 6160
You can ignore the jshint rules for whole file or for particular line or for given block.
Ignoring Line:
function isqrt(n) {
var shift, result, candidateResult;
if (n < 0) {
return false;
}
for (shift = 2; n >> shift; shift += 2) {} // jshint ignore:line
for (result = 0, shift -= 2; shift >= 0; shift -= 2) {
result = result << 1;
candidateResult = result + 1;
if (candidateResult * candidateResult <= n >> shift) {
result = candidateResult;
}
}
return result;
}
Ignoring Block
/* jshint ignore:start */
// Code here will be ignored by JSHint. So write your code here
/* jshint ignore:end */
// Code here will be linted with JSHint.\
or just write // jshint ignore: start
at the start of file then whole file will be ignored
Upvotes: 1
Reputation: 1243
You can do the following
for (shift = 2; n >> shift; shift += 2) {
// do nothing.
}
or Add following in your js
/*jshint noempty: true */
Upvotes: 1