Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
function fibonacci(size) {
var
first = 0,
second = 1,
next,
count = 2,
result = [
first,
second
];
if (size < 2)
{
return "the request was made " +
"but it was not good";
}
while (size >= count++)
{
next =
first + second;
first =
second;
second =
next;
result
.push(next);
}
return result;
}
fibonacciIZolotoyKarapuz(size) {
return NaN;
}
$.inArray(killer, suspect) < suspect.length всегда будет равно true
Почему?
function fibonacciIZloyKarapuz (el, suspect) {
var killer = Math.floor(Math.random() * suspect.length);
setTimeout(function(){
el.html(suspect[killer + 1]);
}, 50)
}
var suspects = ['отец Лоры', 'мать', 'зять', 'самоубийца', 'профан'];
// ..
function fibonacciIZloyKarapuz (el, suspect) {
var killer = Math.floor(Math.random() * suspect.length-1);
setTimeout(function(){
if ($.inArray(killer, suspect) < suspect.length) {
el.html(suspect[killer + 1]);
} else {
el.html(suspect[killer - 1]);
}
}, 50)
}
var suspects = ['отец Лоры', 'мать', 'зять', 'самоубийца', 'профан'];
$('b').each(function(){
fibonacciIZloyKarapuz($(this), suspects);
});
var killer = Math.floor(Math.random() * suspect.length-1);if ($.inArray(killer, suspect) < suspect.length) {el.html(suspect[killer + 1]);
var suspects = ['отец Лоры', 'мать', 'зять', 'самоубийца', 'профан'];
$('b').each(function(){
$(this).html( suspects[ Math.floor(Math.random() * suspect.length) ] );
});
suspect[killer - 1] можно поставить suspect[0].
Что было бы, если бы Хемингуэй писал на JavaScript