<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Вычисление минимума массива]]></title><description><![CDATA[<p dir="auto">Как вычислить минимум из массива? Тоже одна из частеньких задач которые можно встретить при изучении JS, аналогично той что писал ранее про <a href="https://forum.exlends.com/topic/278/zaciklennyj-slajder" target="_blank" rel="noopener noreferrer">зацикливание слайдера</a>.</p>
<p dir="auto">И так сначала минимальным считается первый (с индексом 0) элемент массива. Далее в цикле <code>for</code> мы сравниваем каждый следующий элемент массива. Если сравниваемый элемент меньше нашего минимума, он становится новым минимумом.<br />
Вот как это можно реализовать:</p>
<pre><code class="language-js">let arr = [8, 62, 59, 3, 81, 2, 8, 93, 4]; 

min = arr[0];      // минимум
min_index = 0;     // индекс min

console.log('Массив:');

for (i = 1; i &lt; arr.length; i++) {
    if (arr[i] &lt; min) {
        min = arr[i];
        min_index = i;
    }
    console.log(arr[i] + " ");
}

console.log('Минимум: ' + min);
console.log('Индекс: ' + min_index);
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/fc/b2/44/1760964120320-%C3%B0-%C3%B0-%C3%B0-%C3%B0-%C3%B0-%C3%B0%C2%BA-%C3%B1-%C3%B0%C2%BA%C3%B1-%C3%B0-%C3%B0-%C3%B0-2025-10-20-%C3%B0-15.41.51.webp" alt="Снимок экрана 2025-10-20 в 15.41.51.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">А теперь разберемся что тут происходит, сначала мы считаем минимальным элемент с индексом 0. Далее выводим этот минимальный элемент, поскольку обработка массива начинается с индекса 1 (сравнивать 0-й элемент с 0-м элементом нет смысла). В цикле мы проверяем, не является ли текущий элемент минимальным, и если это так то устанавливаем новый минимум. Для идентификации минимума используются две переменных — <code>min</code> (минимум) и <code>min_index</code> (индекс минимума). Также в цикле мы выводим обрабатываемый элемент.</p>
]]></description><link>https://forum.exlends.ru/topic/280/vychislenie-minimuma-massiva</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 15:45:54 GMT</lastBuildDate><atom:link href="https://forum.exlends.ru/topic/280.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Oct 2025 12:38:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Вычисление минимума массива on Mon, 20 Oct 2025 14:33:18 GMT]]></title><description><![CDATA[<p dir="auto">@Jspi Ну как минимум самые маленькие точно про тернарные операторы мало что знаю, тут же дело в развитии логического мышления. Глянь сколько всего надо придумать на <code>for</code> и <code>if</code>.</p>
<p dir="auto">А тут ты взял аккумы и итемы туда сюда <img src="https://forum.exlends.ru/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=a1e94250dac" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":(" alt="😞" /></p>
]]></description><link>https://forum.exlends.ru/post/901</link><guid isPermaLink="true">https://forum.exlends.ru/post/901</guid><dc:creator><![CDATA[kirilljsx]]></dc:creator><pubDate>Mon, 20 Oct 2025 14:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to Вычисление минимума массива on Mon, 20 Oct 2025 14:20:47 GMT]]></title><description><![CDATA[<p dir="auto">А разве редьюс  только для про?)</p>
]]></description><link>https://forum.exlends.ru/post/900</link><guid isPermaLink="true">https://forum.exlends.ru/post/900</guid><dc:creator><![CDATA[Aladdin]]></dc:creator><pubDate>Mon, 20 Oct 2025 14:20:47 GMT</pubDate></item><item><title><![CDATA[Reply to Вычисление минимума массива on Mon, 20 Oct 2025 14:20:17 GMT]]></title><description><![CDATA[<p dir="auto">@Jspi Ну вот чего ты начинаешь редьюсом наезжать? Мы ж для самых маленьких пишем))</p>
]]></description><link>https://forum.exlends.ru/post/893</link><guid isPermaLink="true">https://forum.exlends.ru/post/893</guid><dc:creator><![CDATA[kirilljsx]]></dc:creator><pubDate>Mon, 20 Oct 2025 14:20:17 GMT</pubDate></item><item><title><![CDATA[Reply to Вычисление минимума массива on Mon, 20 Oct 2025 12:47:06 GMT]]></title><description><![CDATA[<pre><code class="language-js">let arr = [8, 62, 59, 3, 81, 2, 8, 93, 4]; 

const min = arr.reduce((acc, item) =&gt; {
   return item &lt; acc ? item : acc;
}, Infinity)

</code></pre>
]]></description><link>https://forum.exlends.ru/post/892</link><guid isPermaLink="true">https://forum.exlends.ru/post/892</guid><dc:creator><![CDATA[Aladdin]]></dc:creator><pubDate>Mon, 20 Oct 2025 12:47:06 GMT</pubDate></item></channel></rss>