<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: duncan1022</title>
    <description>The latest articles on DEV Community by duncan1022 (@duncan1022).</description>
    <link>https://dev.to/duncan1022</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1208344%2F0a1a5c5e-bdf0-48f0-be6c-c70a25471e75.png</url>
      <title>DEV Community: duncan1022</title>
      <link>https://dev.to/duncan1022</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/duncan1022"/>
    <language>en</language>
    <item>
      <title>Decoding Algorithms with Pseudocode</title>
      <dc:creator>duncan1022</dc:creator>
      <pubDate>Wed, 17 Jan 2024 02:24:37 +0000</pubDate>
      <link>https://dev.to/duncan1022/decoding-algorithms-with-pseudocode-124i</link>
      <guid>https://dev.to/duncan1022/decoding-algorithms-with-pseudocode-124i</guid>
      <description>&lt;p&gt;Introduction to Pseudocode:&lt;/p&gt;

&lt;p&gt;Pseudocode serves as an informal and high-level representation of actual code, providing a clear and concise way to illustrate how an algorithm or computer program functions using plain English. It acts as a bridge between the initial concept of a solution and the detailed implementation in a programming language. Unlike formal code, pseudocode is not bound by the syntax rules of any specific programming language, making it accessible to individuals with varying levels of programming. This allows developers to focus on the logic and structure of their algorithms without getting bogged down by language-specific details. Pseudocode is a powerful tool in the early stages of problem-solving, aiding in the planning and understanding of complex algorithms before they are translated into usable code. Its simplicity and flexibility make it an invaluable asset for both beginners learning the basics of programming and experienced developers designing complex solutions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q504XF-r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y97sj3n8l173jvgd1gri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q504XF-r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y97sj3n8l173jvgd1gri.png" alt="example of pseudocode" width="398" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why Use Pseudocode?&lt;/p&gt;

&lt;p&gt;Creating pseudocode enables you to articulate your ideas without the burden of dealing with the syntax of a programming language. Due to its absence of specific syntax, pseudocode is straightforward to both comprehend and compose. This simplicity facilitates effective communication of ideas and concepts among programmers, encouraging collaboration even when individuals are using distinct programming languages.&lt;/p&gt;

&lt;p&gt;How to Write Pseudocode&lt;/p&gt;

&lt;p&gt;To create pseudocode effectively, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Define the problem: &lt;br&gt;
Ensure a thorough understanding of the problem before starting pseudocode writing. Consider the problem's inputs, outputs, and overall requirements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Identify the main steps:&lt;br&gt;
Deconstruct the problem into elements and pinpoint the key steps essential for its resolution. Consider the logic necessary to attain the desired outcome.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write the header:&lt;br&gt;
Start your pseudocode with a header providing an overview of the problem. Include the algorithm's name and a brief description of its purpose.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Express logic using constructs:&lt;br&gt;
Utilize constructs like sequence, case, while, repeat-until, for, and if-then-else to articulate the logic and flow of your program. These constructs should outline the steps needed to solve the problem.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use variables and data structures:&lt;br&gt;
Use variables and data structures to store data within your program. Declare them with descriptive names and data types to show the intended representation of data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use clear, concise language:&lt;br&gt;
Pseudocode should use clear and concise language for easy comprehension. Steer clear of overly technical terms or intricate syntax that might weigh down understanding of your program's logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test and refine:&lt;br&gt;
Validate your pseudocode by mentally or physically running through it. Ensure it covers all necessary cases and accurately reflects the program's logic and flow.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// JavaScript Code: Finding the Sum of Even Numbers in an Array

// Function to calculate the sum of even numbers in an array
function calculateSumOfEvens(array) {
    // Initialize a variable to store the sum
    let sum = 0;

    // Loop through each element in the array
    for (let i = 0; i &amp;lt; array.length; i++) {
        // Check if the element is an even number
        if (array[i] % 2 === 0) {
            // Add the even number to the sum
            sum = sum + array[i];
        }
    }

    // Return the final sum
    return sum;
}

// Example usage
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let result = calculateSumOfEvens(numbers);
console.log(result); // Output: 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Pseudocode: Finding the Sum of Even Numbers in an Array

// Function to calculate the sum of even numbers in an array
function calculateSumOfEvens(array) {
    // Initialize a variable to store the sum
    let sum = 0;

    // Loop through each element in the array
    for each element in array {
        // Check if the element is an even number
        if element is even {
            // Add the even number to the sum
            sum = sum + element;
        }
    }

    // Return the final sum
    return sum;
}

// Example usage
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let result = calculateSumOfEvens(numbers);
print(result); // Output: 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Advantages of Pseudocode:&lt;/p&gt;

&lt;p&gt;Clarity and Readability: Pseudocode combines natural language with programming elements, enhancing readability and comprehension. &lt;/p&gt;

&lt;p&gt;Ease of Writing: Writing pseudocode is generally quicker and simpler than writing actual code, as it doesn't need to adhere to the syntax of a specific programming language. It is useful for sketching program ideas and testing logic.&lt;/p&gt;

&lt;p&gt;Flexibility: Independent of a specific programming language, pseudocode allows the expression of program logic without being tied to implementation details. This flexibility supports exploring different design options and facilitates communication among team members using diverse programming languages.&lt;/p&gt;

&lt;p&gt;Faster Prototyping: Pseudocode's informality and flexibility make it suitable for rapid prototyping and idea testing, potentially saving time compared to writing, debugging, and testing actual code.&lt;/p&gt;

&lt;p&gt;Testing: Pseudocode serves as a tool to test logic, identifying flaws before actual implementation. This aids in catching bugs early in the development process, reducing debugging efforts later on.&lt;/p&gt;

&lt;p&gt;Disadvantages of Pseudocode:&lt;/p&gt;

&lt;p&gt;No Standardization: Lack of standard syntax or formatting for pseudocode can make it challenging to write and read from different sources, leading to potential confusion and misinterpretation.&lt;/p&gt;

&lt;p&gt;Non-Executable: Pseudocode cannot be executed, hindering its ability to test logic directly. This limitation complicates the validation of ideas and may result in challenges during code implementation.&lt;/p&gt;

&lt;p&gt;Limited Functionality: Pseudocode is constrained to expressing high-level concepts and lacks the detailed control and functionality of actual code. This limitation makes it more challenging to test complex operations.&lt;/p&gt;

&lt;p&gt;Translation Errors: Translating pseudocode into actual code may introduce errors or misunderstandings due to differences in syntax or functionality between pseudocode and the chosen programming language, potentially leading to bugs and issues.&lt;/p&gt;

&lt;p&gt;Lack of Documentation: Pseudocode lacks detailed documentation and comments typically found in actual code. This absence may hinder understanding and maintenance, especially for team members unfamiliar with the program logic.&lt;/p&gt;

&lt;p&gt;The decision to use pseudocode should be based on the specific needs and context of the development process&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;/p&gt;

&lt;p&gt;In conclusion, pseudocode emerges as a powerful ally in the realm of software development, offering a versatile and expressive means to articulate algorithms and program logic. Its strength lies in its ability to transcend the constraints of programming language syntax, providing a clear and accessible representation for both novice and seasoned developers. The advantages of pseudocode, including clarity, ease of writing, and flexibility, contribute to its widespread utility in the early stages of problem-solving. However, it is essential to acknowledge its limitations, such as the lack of standardization and non-executability, which may pose challenges in certain contexts. While pseudocode serves as an invaluable tool for ideation, communication, and algorithmic design, developers should be mindful of striking a balance between its benefits and constraints within the broader development process. Ultimately, the use of pseudocode can significantly enhance collaboration, understanding, and efficiency in software development endeavors.&lt;/p&gt;

&lt;p&gt;Resources:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements"&gt;https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/"&gt;https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/what-is-pseudocode-in-programming/"&gt;https://www.freecodecamp.org/news/what-is-pseudocode-in-programming/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.povertyactionlab.org/sites/default/files/research-resources/rr_datacleaning_Pseudocode.pdf"&gt;https://www.povertyactionlab.org/sites/default/files/research-resources/rr_datacleaning_Pseudocode.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Image sources:&lt;br&gt;
&lt;a href="https://i.pinimg.com/736x/b5/7e/ff/b57effccfadc2ea612d997a0fbfa27bc.jpg"&gt;https://i.pinimg.com/736x/b5/7e/ff/b57effccfadc2ea612d997a0fbfa27bc.jpg&lt;/a&gt;&lt;br&gt;
&lt;a href="https://static1.squarespace.com/static/54777fa6e4b0f8c456faf5b9/t/5f1af3077b50687ed2506c62/1595601674854/Future+Device+Pseudocode+-+Gr.+5-9.pdf"&gt;https://static1.squarespace.com/static/54777fa6e4b0f8c456faf5b9/t/5f1af3077b50687ed2506c62/1595601674854/Future+Device+Pseudocode+-+Gr.+5-9.pdf&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>learning</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Scope In JavaScript</title>
      <dc:creator>duncan1022</dc:creator>
      <pubDate>Fri, 01 Dec 2023 19:21:35 +0000</pubDate>
      <link>https://dev.to/duncan1022/scope-in-javascript-4o5g</link>
      <guid>https://dev.to/duncan1022/scope-in-javascript-4o5g</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Introduction &lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
    To understand Scopes, we need to understand some fundamentals. You need to have an idea of what and how variables work. A variable is a tool that we use to store a value to be used later on in our code. Then we need to initialize our variables. We have to follow a two-step procedure.&lt;br&gt;
    Our first step is to declare our variable, and our second step is to assign it a value. We can do this by utilizing our reserve words &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;const&lt;/code&gt;, and our black sheep &lt;code&gt;var&lt;/code&gt;. &lt;code&gt;let&lt;/code&gt; is not going to allow us to redeclare our variable, but will allow you to reassign its value. &lt;code&gt;const&lt;/code&gt; is more strict, not allowing our variable to be redeclared or its value to be reassigned. &lt;code&gt;var&lt;/code&gt; is outdated and is bad practice to use in current code. While it used to be the main way to declare variables, it causes issues in the Scope and leads to unpredictable bugs within our code. You will mainly see this used in legacy codes. This understanding is extremely important to achieving anything in JavaScript.&lt;br&gt;
    With our new knowledge of variables, we can move on to our Scopes. Scopes are the areas in our code where variables are located. This will affect how that variable can be accessed and used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Types of Scopes&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Global Scope&lt;/li&gt;
&lt;li&gt;Function Scope&lt;/li&gt;
&lt;li&gt;Block Scope&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Scope Breakdown&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Global Scope &lt;br&gt;
This variable is declared outside of any function and is typically found at the top of our code. We can also access this variable from anywhere in our code. This is because of the Scope Chain (I'll explain this further in the blog).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Function Scope&lt;br&gt;
This is a variable declared within a function and is only accessible within that same function. This is also known as our Local Scope, which contains local variables (variables located inside a function). These two categories of scope go hand-in-hand.&lt;br&gt;
&lt;em&gt;Knowledge Nugget: Since each function creates a new Scope, variables with the same name can be used in different functions.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Block Scope&lt;br&gt;
This is a variable declared inside of a block &lt;code&gt;{ }&lt;/code&gt; and cannot be accessed outside the block.&lt;br&gt;
&lt;em&gt;Knowledge nugget: JavaScript had only Global Scope and Function Scope prior to ES6 (2015).ES6 created two new important JavaScript declarations:&lt;/em&gt; &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;&lt;em&gt;. These two declarations enable us to use Block Scope in JavaScript.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Scope Chain &lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
    Every Scope works in a chain. Meaning in a sequence, these Scopes are organized with the nested function's Scope inheriting from its surrounding Scope as its parent, and name searches progress up the Scope chain from the child to the parent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw24m1lhqymvep15ygw7z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw24m1lhqymvep15ygw7z.jpg" alt="Diagram displaying each Scope"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Scope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accessible in every Scope&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Function Scope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accessible within the function&lt;/li&gt;
&lt;li&gt;specific to a single function&lt;/li&gt;
&lt;li&gt;can't be accessed by anything in the outer Scopes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Block Scope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accessible within the block&lt;/li&gt;
&lt;li&gt;specific to a single block&lt;/li&gt;
&lt;li&gt;can't be accessed by anything in the outer Scopes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Conclusion&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
    Understanding the fundamentals of variable declaration, assignment, and the distinctions between &lt;code&gt;let&lt;/code&gt; &lt;code&gt;const&lt;/code&gt;, and &lt;code&gt;var&lt;/code&gt; is crucial. The learning placement of these fundamentals paves the way for delving into the three essential Scopes: Global, Function, and Block.&lt;br&gt;
    The Global Scope, normally placed outside functions, allows accessibility throughout the entire code. While the Function Scope confines variables within specific functions, creating distinct Scopes for each function, the Block Scope follows in the same footprints as the Function Scope but for block variables only.&lt;br&gt;
    The Scope Chain provides a flow of how our Scopes should behave not only alone but with one another. Providing an order in how variables may interact with their surrounding Scopes and guiding name searches from child to parent.&lt;br&gt;
    Once we tackle and conquer our fundamentals, the rest comes with ease. Just remember the flow of code, and Scope will come naturally. Many coders are using each Scope without even realizing it!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Resources&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;General variable explanations&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/learn-co-curriculum/phase-0-pac-1-js-variables" rel="noopener noreferrer"&gt;https://github.com/learn-co-curriculum/phase-0-pac-1-js-variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/learn-co-curriculum/phase-1-lecture-videos-scope" rel="noopener noreferrer"&gt;https://github.com/learn-co-curriculum/phase-1-lecture-videos-scope&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;General scope explanations &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/js/js_scope.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_scope.asp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/learn-co-curriculum/phase-1-scope-readme" rel="noopener noreferrer"&gt;https://github.com/learn-co-curriculum/phase-1-scope-readme&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Knowledge nugget in Block  and Function Scope sections&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/js/js_scope.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_scope.asp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scope chain&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/learn-co-curriculum/phase-1-scope-chain-readme" rel="noopener noreferrer"&gt;https://github.com/learn-co-curriculum/phase-1-scope-chain-readme&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/learn-co-curriculum/phase-1-lecture-videos-scope" rel="noopener noreferrer"&gt;https://github.com/learn-co-curriculum/phase-1-lecture-videos-scope&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
