<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming basics on AminBytes</title><link>https://aminbytes.dev/bytes/programming/</link><description>Recent content in Programming basics on AminBytes</description><generator>Hugo</generator><language>en</language><atom:link href="https://aminbytes.dev/bytes/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Variables</title><link>https://aminbytes.dev/bytes/programming/variables/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/programming/variables/</guid><description>&lt;p&gt;A &lt;a class="gl" href="https://aminbytes.dev/glossary/#variable" data-gl="variable" data-gl-term="Variable" data-gl-def="A name that points to a value, so you can use the name instead of repeating the value."&gt;&lt;strong&gt;variable&lt;/strong&gt;&lt;/a&gt; is a name that points to a value. You give a value a name once, then use the name instead of repeating the value.&lt;/p&gt;</description></item><item><title>Functions</title><link>https://aminbytes.dev/bytes/programming/functions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/programming/functions/</guid><description>&lt;p&gt;A &lt;a class="gl" href="https://aminbytes.dev/glossary/#function" data-gl="function" data-gl-term="Function" data-gl-def="A named piece of logic that takes inputs, does some work and usually returns a result."&gt;&lt;strong&gt;function&lt;/strong&gt;&lt;/a&gt; takes inputs, does some work and usually returns a result.&lt;/p&gt;&#10;&lt;h2 id="defining-a-function"&gt;Defining a function&lt;a class="anchor" data-pagefind-ignore="all" href="#defining-a-function" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;figure class="code has-title"&gt;&#10; &lt;div class="code-head" data-pagefind-ignore="all"&gt;&lt;span class="code-title"&gt;math.ts&lt;/span&gt;&lt;span class="code-lang"&gt;ts&lt;/span&gt;&#10; &lt;button class="code-copy" type="button" aria-label="Copy code"&gt;Copy&lt;/button&gt;&#10; &lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-ts" data-lang="ts"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kr"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;: &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;: &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;5&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 5&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/figure&gt;&#10;&lt;h2 id="pure-functions"&gt;Pure functions&lt;a class="anchor" data-pagefind-ignore="all" href="#pure-functions" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;A function is &lt;a class="gl" href="https://aminbytes.dev/glossary/#pure-function" data-gl="pure-function" data-gl-term="Pure function" data-gl-def="A function that always gives the same output for the same inputs and changes nothing outside itself. Easy to test."&gt;&lt;em&gt;pure&lt;/em&gt;&lt;/a&gt; when the same inputs always give the same output and it changes nothing outside itself. Pure functions are easy to test.&lt;/p&gt;</description></item></channel></rss>