Learn Functional Programming by Building a Spreadsheet: Step 53-78 | freeCodeCamp | JavaScript

Поделиться
HTML-код
  • Опубликовано: 15 сен 2024
  • 🔗Course Link: www.freecodeca...
    🔗Courses Playlist Link: • Full and Partial Courses
    🌟 "Master Functional Programming: Build an Interactive Spreadsheet App" 🌟
    🔍 Embark on a transformative coding journey with FreeCodeCamp as you dive into the world of functional programming by building a sophisticated Spreadsheet application. Functional programming is a powerful paradigm that emphasizes writing software using pure functions and avoiding shared state, side effects, and mutable data. This approach can lead to easier-to-understand, more reliable, and more testable code.
    In this project, you will apply the principles of functional programming to develop a dynamic spreadsheet that not only performs calculations and manages data efficiently but also updates interactively based on user input. You'll learn how to parse and evaluate mathematical expressions, handle cell references, and implement essential spreadsheet functions like sum, average, and complex mathematical operations.
    📌 Core Learning Objectives:
    1. *Deep Dive into Functional Programming:* Explore how to structure your code using small, reusable functions that are combined to build complex functionality.
    2. *Advanced JavaScript Methods:* Utilize advanced JavaScript methods such as `map()`, `find()`, `parseInt()`, and `includes()` to manipulate data and implement functionality within your spreadsheet.
    3. *Interactive Web Interface Development:* Learn how to create responsive and dynamic user interfaces that react to user inputs, making your spreadsheet both functional and user-friendly.
    📊 Applying Theoretical Concepts Practically:
    This project will challenge you to apply theoretical concepts of functional programming in a practical, real-world application. By building a functional and interactive spreadsheet, you will see firsthand how functional programming can be used to enhance the scalability and maintainability of web applications.
    ✏️ Step-by-Step Building Process:
    Follow our detailed, step-by-step guide that will walk you through each phase of building your spreadsheet application. From setting up your project environment to writing functions that handle complex calculations and UI updates, each step is designed to enhance your understanding and skills in functional programming and JavaScript.
    🌍 Community Collaboration and Feedback:
    After completing your spreadsheet, engage with the FreeCodeCamp community to share your project, receive feedback, and discuss the challenges and successes you encountered. This collaborative experience is invaluable for gaining new perspectives and improving your coding skills.
    📈 Boosting Your Developer Portfolio:
    Completing this spreadsheet project not only broadens your skillset in functional programming and JavaScript but also adds a significant and innovative project to your portfolio, demonstrating your ability to apply modern programming paradigms in building complex web applications.
    Celebrate your accomplishment upon completing the interactive spreadsheet, and look forward to tackling more advanced projects that push your programming skills and creativity to new heights.
    #FunctionalProgramming #JavaScript #SpreadsheetApp #WebDevelopment #CodingProject #LearnToCode #FreeCodeCamp #DeveloperCommunity 🌟🔍📌✏️📘🌍📈
    📚 Further expand your web development knowledge:
    FreeCodeCamp Series: • 1. freeCodeCamp Respon...
    Javascript Codewars Series: • 31. codewars 8 kyu
    💬 Connect with us:
    Facebook: www.facebook.c...
    Twitter: / _codemans
    Instagram: / codemansuniversal
    I'm coming for those spots, T-Series / MrBeast.

Комментарии • 14

  • @alexanderroan
    @alexanderroan 2 месяца назад +4

    For people struggling with this I tried to write down what evalFormula is doing in my notes as I was working through it. I think I'm clear-ish on what each part of it does, but with the level of currying I have a really hard time tracing the parameters through the process. Anyway here is my sumary:
    Summary explanation of each part
    - parameter: x, cells
    - constant rangeRegex representing format of a range e.g. A1:B25
    - constant cellRegex representing format of a call e.g. A1
    - idToText: Take a cell ID and return it's value e.g. A12 returns A12 value
    - rangeFromString: Take 2 numbers and return an array range
    - Example: 5 and 10 returns `[5, 6, 7, 8, 9, 10]`
    - elemValue: Take a num & char, create a cell ID, return that cells value
    - Example: 5 and B returns B5 returns B5 value
    - addCharacters:
    - Take two chars e.g. D and G and return `[D, E, F, G]`
    - Use elemValue(num) on it to get e.g. `[D5, E5, F5, G5]`
    - Use idToText to get the cell values.
    - rangeExpanded:
    - Takes x which is a range e.g. A12:B16, breaks down into char1, num1 etc.
    - Use num1 and 2 to create array `[12, 13, 14, 15, 16]`
    - Use addCharacters to get `[A, B]` and uses map on above so you get:
    - `[A12, A13, A14, A15, A16]`, `[B12, B13, B14, B15, B16]`
    - cellExpanded:
    - Takes range expanded, replaces based on cell format the cell ID with values
    Bit more detailed notes that I took with the code lines for clarity:
    ```jsx
    // declare function with parameters x? and cells?
    const evalFormula = (x, cells) => {
    // 1st function takes an id (e.g. A12) and finds that cell and returns the cell value
    // id comes from elemValue (character + num)
    // cells comes from evalFormula parameter
    const idToText = id => cells.find(cell => cell.id === id).value;
    // declare regex for an address and a range
    const rangeRegex = /([A-J])([1-9][0-9]?):([A-J])([1-9][0-9]?)/gi;
    const cellRegex = /[A-J][1-9][0-9]?/gi;
    // return an array with a range from two string values
    const rangeFromString = (num1, num2) => range(parseInt(num1), parseInt(num2));
    // take a number and character, join to make an id, find the cell and return value
    const elemValue = num => character => idToText(character + num);
    // goal: return a range of cell ids
    // 1) Takes two chars e.g. D, G and returns [D, E, F, G]
    // 2) Maps this with elemValue(num), so applies a num to each D, E, F, G = D5, E5, F5, G5
    // 3) Then uses that id to get the cell value e.g. [1, 2, 3, 4]
    const addCharacters = character1 => character2 => num => charRange(character1, character2).map(elemValue(num));
    // replace takes a callback with parameter starting with match and four variables
    // if x is A12:C16, char 1 = A, num1 = 12, char 2 = C, num 2 = 16
    // rangeFromString takes 12 and 16 and returns [12, 13, 14, 15, 16]
    // addCharacters takes A and C and returns [A, B, C] for each range:
    // - [[A12, A13, A14, A15, A16], [B12, B13, B14, B15, B16]]
    const rangeExpanded = x.replace(rangeRegex, (_match, char1, num1, char2, num2) => rangeFromString(num1, num2).map(addCharacters(char1)(char2)));
    // Now we are calling replace on the above range
    // with cell format running idToText so replacing with the cell values
    const cellExpanded = rangeExpanded.replace(cellRegex, match => idToText(match.toUpperCase()));
    }
    ```

    • @codeManS
      @codeManS  2 месяца назад +1

      Thanks for letting us know!

  • @mitsk2002
    @mitsk2002 2 месяца назад +2

    Daaaaaamn I didn't know FCC had that much profit in just one year! Kinda hard not to get annoyed with the wording of some of these steps now, lol.

    • @codeManS
      @codeManS  2 месяца назад +2

      Yeah, they're acting like paupers when they're rolling in dough

  • @alexgalal4939
    @alexgalal4939 3 дня назад +1

    if aids was in code this would be it. this was pure HIV screw this challenge. thanks for giving us the solutions dude u saved a ton of us.

    • @codeManS
      @codeManS  3 дня назад

      You're welcome and yeah, that one's pretty awful

  • @pkxdzardoofficial289
    @pkxdzardoofficial289 11 дней назад +1

    Thank you bro

    • @codeManS
      @codeManS  11 дней назад

      You're welcome!

  • @TheSpacecamel
    @TheSpacecamel Месяц назад +4

    in a professional enviroment, if they gave me this code, I would hate them. This is the most unreadable code. They are trying to win a fewest character coding contest with this crap instead of breaking things down into small easy to understand steps.

    • @codeManS
      @codeManS  Месяц назад +1

      It is what it is with these guys

  • @Karadonblack
    @Karadonblack 2 месяца назад +1

    Nope i have no idea i only got parts and pieces of it man lol

    • @codeManS
      @codeManS  2 месяца назад

      Yeah this one's pretty bad. Did you already do the legacy course and run through a bunch of codewars challeneges?

  • @aletter1718
    @aletter1718 5 дней назад +1

    Ill be honest with you, this portion of the course probably is the worst so far. I usually defend them because they are free, but This is possibly the worst way to go about explaining functional programming in a JavaScript context. To be fair, functional programming is hard as is for most programmers in general, not even being a student. It doesn't fit into your brain neatly like OOP does. The biggest reason I like it is it makes it much easier to read the code, so I can hack it easier and have a good understanding on how to break it from the perspective of someone who does bug bounties. I showed this to folks I know who program and get paid for it and even they were like ?????. Whoever wrote some of these steps Im farting when their mouth is open. If I had paid for this i would be angry.

    • @codeManS
      @codeManS  5 дней назад +1

      Yeah, I actually sighed thinking about it. It is what it is though.