<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>JSON Sample</title>
</head>
<body>
<h2>Текст</h2>
<div id="placeholder"></div>
<script>
document.addEventListener(
'DOMContentLoaded',
() => {
fetch('data.json')
.then((response) => response.json())
.then((data) => {
document.getElementById("placeholder").innerHTML =
`<ul>${data.users.map((u) => `<li>${u.firstName} ${u.lastName} -- ${u.joined.month}</li>`).join()}</ul>`
});
},
);
</script>
</body>
</html>
function encodeWav(array $raw) : array
{
$result = "RIFF"
. pack('V', count($raw))
. "WAVEfmt "
. pack('V', 16)
. pack('v', 1)
. pack('v', TTS_DEFAULT_OPTIONS['numChannels'])
. pack('V', TTS_DEFAULT_OPTIONS['sampleRate'])
. pack('V', TTS_DEFAULT_OPTIONS['sampleRate'] * 4)
. pack('v', 4)
. pack('v', 16)
. 'data'
. pack('V', count($raw) * 2);
$volume = 1;
foreach ($raw as $unit) {
$result .= pack('v', $unit * $volume);
}
return [
'type' => 'audio/x-wav',
'content' => $result
];
}
(step == undefined || step == null || (step == 0 && start < end))
Соответственно, при вычислении получаете true || true || (false && false)
, что даёт true и третье условие срабатывает.const range = (start, end, step = 1) => {
if (step === 0 || isNaN(Number(step))) {
throw new Exception('Неверное значение step');
}
if (start < end && step < 0 || start > end && step > 0) {
step = -step;
}
const n = Math.floor((end - start) / step) + 1;
return Array(n).fill(1).map((v, i) => start + step * i);
}
console.log(range(10, 1));
// Array(10) [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]