GithubHelp home page GithubHelp logo

javascript-exercises's Introduction

JavaScript Exercises

These JavaScript exercises are intended to complement the JavaScript content on The Odin Project (TOP). They should only be done when instructed during the course of the curriculum.

Contributing

If you have a suggestion to improve an exercise, an idea for a new exercise, or notice an issue with an exercise, please feel free to open an issue after thoroughly reading our contributing guide.

How To Use These Exercises

  1. Fork and clone this repository. To learn how to fork a repository, see the GitHub documentation on how to fork a repo.

    • Copies of repositories on your machine are called clones. If you need help cloning to your local environment you can learn how from the GitHub documentation on cloning a repository.
  2. Before you start working on any exercises, you should first ensure you have the following installed:

    • NPM. You should have installed NPM already in our Installing Node.js lesson. Just in case you need to check, type npm --version in your terminal. If you get back Command 'npm' not found, but can be installed with:, do not follow the instructions in the terminal to install with apt-get as this causes permission issues. Instead, go back to the installation lesson and install Node with NVM by following the instructions there.
    • Jest. After cloning this repository to your local machine and installing NPM, go into the newly created directory (cd javascript-exercises) and run npm install. This will install Jest and set up the testing platform based on our preconfigured settings. (Note: if you get warnings that packages are out of date or contain vulnerabilities, you can safely ignore them for these exercises.)
  3. Each exercise includes the following:

    • A markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests.
    • A solutions directory that contains a solution and the same test file with all of the tests unskipped.

    To complete an exercise, you'll need to go to the exercise directory with cd exerciseName in the terminal and run npm test exerciseName.spec.js. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass.

  4. Some of the exercises have test conditions defined in their spec file as test.skip compared to test. This is purposeful. After you pass one test, you will change the next test.skip to test and test your code again. You'll do this until all conditions are satisfied. All tests must pass at the same time, and you should not have any test.skip instances by the time you finish an exercise.

  5. Once you successfully finish an exercise, check the solutions directory within each exercise to compare it with yours.

    • You should not be checking the solution for an exercise until you finish it!
    • If your solution differs wildly from TOP's solution (and still passes the exercise's requirements), that's completely fine. Do feel free to ask about it in our Discord if there are parts you do not understand.
  6. Do not submit your solutions to this repo, as any PRs that do so will be closed without merging.

Note: Due to the way Jest handles failed tests, it may return an exit code of 1 if any tests fail. NPM will interpret this as an error and you may see some npm ERR! messages after Jest runs. You can ignore these, or run your test with npm test exerciseName.spec.js --silent to supress the errors.

The first exercise, helloWorld, will walk you through the process in-depth.

Debugging

To debug functions, you can run the tests in the Visual Studio Code debugger terminal. You can open this by clicking the "Run and Debug" icon on the left or pressing Ctrl + Shift + D, then clicking JavaScript Debug Terminal. You will be able to set breakpoints as you would in the Chrome DevTools debugger. You can run npm test exerciseName.spec.js to then execute your code up until your breakpoint and step through your code as necessary. NOTE: To take advantage of the debugger, you MUST run the script in the debugger terminal, not the bash or zsh terminal.

Adding a new exercise

To add a new exercise:

  1. Be sure you've ran npm install at the root of the javascript-exercises directory
  2. Run the command npm run generate
  3. When prompted, enter the name of the new exercise in camelCase syntax

After entering an exercise name, a new directory with the necessary files will be created. You will then need to update the README.md and spec.js files as well as the files in the solution directory of the new exercise.

javascript-exercises's People

Contributors

01zulfi avatar 105ron avatar alex-nemet avatar asartea avatar bycdiaz avatar cats256 avatar codyloyd avatar couchoftomato avatar dependabot[bot] avatar eboisseausierra avatar fruddenfeldt avatar groundedcastle avatar i3uckwheat avatar imrogerjiang avatar jamienorthman avatar kevinmulhern avatar kumang-subba avatar leila-alderman avatar manonlef avatar maoshizhong avatar marlatte avatar marvingay avatar remtaine avatar rushiljalal avatar sama-004 avatar seoul2045 avatar thatblindgeye avatar twalton83 avatar vrarora avatar xandora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-exercises's Issues

Add numbering on exercise folders

It would be more intuitive if the folders were numbered so that they can be done in order. For example, they could be called "01 Hello World", "02 Repeat String", and so on. Their number was mentioned in each of their individual README files, but having the folder themselves labelled doesn't add much effort and makes things easier to go through.

I know the project README says that since it's "still in the process of creating more exercises the order is subject to change and has not yet been specified", but The Odin Project courses already recommend a specific order so I think it can be added on the folder name

No coding explanations in the solutions branch

Could we (odin students) have a detailed explained to what is going on in the code? Sometimes the code looks alien to me, like this one in removeFromArray.js :

var removeFromArray = function(...args) {
const array = args[0]
return array.filter(val => !args.includes(val))
}

I have no idea what "..." , "=>" , !args does

It looks too advanced from the level where I am at (I am following odin curriculum)

Find The Oldest, No Way To Prove Tests

In Find The Oldest.spec.js, there is no way to prove if someone is still living. In test two the file only checks the return value of "Ray".
Also, the third test doesn't check if the oldest is still living, it just checks who was sent. Not only would it be pointless to complete these conditions, but I wouldn't even know if I did them correctly lol.

How to use Jasmine ?

I had to quickly google how to use Jasmine. It is actually quite simple but it could have been mentioned in the main README.md right after the instructions on how to install Jasmine.

Thank you for the content

Palindrome exercise

In palindrome exercise the strings with dot [.] at the end shouldn't be false ? I think its more accurate this way, maybe.
Thank you

Bug - : tempConversion: Doesn't skip test cases

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

** Description of the Bug:**
The first time I run the code with the 'npm test tempConversion.spec.js' it should only test it with those test cases that doesn't have de '.skip' method. Right now the code its been test with all the test cases even though they have the '.skip' method

** Desktop/Device:**

  • Device: MacBook Air
  • OS: MacOS Mojave 10.14.5

No specs found

This is regarding the repeatString exercise.

I finished Hello,World and it worked fine.

When i moved on to repeatString i kept getting 'No specs found'. Eventually I copied/pasted the answer code into the test to make sure everything was working right with the computer and I still get back 'No specs found'

Is there anyone able to guide me on what to do next to fix this problem?

Thank you!

Add arguments to repeatString README

Because:

A significant amount of students misunderstand the example function call and omit arguments from their solutions, leading to ultimately incorrect code.

We should:
explicitly state the necessary parameters in the README, but tell students that the following exercises will not have the arguments provided so they should read the README and the tests carefully to see what kind of arguments are expected.

Acceptance Criteria:

  • A little blurb stating that the function takes two arguments, string and num, and an additional mention that the following exercises will not have the arguments provided to them as per the above.

Jasmine error in tempConversion

I'm getting this error upon running jasmine tempConversion.spec.js in the terminal:

image

I checked my copy of the spec and it's identical to the spec file in the repo.

leapYears

An alternative solution.
I used Venn diagrams. Look at this graphic: https://bit.ly/2VrspFB
Where:
A: numbers divisible by 400
B: numbers divisible by 100
C: numbers divisible by 4
We need A and the area between C and B. This can be expressed in set theory as:
(C - B) U A = (C ∩ ¬B) U A
The expression above can be traduced to:
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
This solution is simplier to explain in this way than the other solution. Both should be considered.
I think explaining this bit of math will make it easier to understand.

10_fibonacci: add test for fibonacci(0)

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Feature Request:

The current accepted solution has a check for fibonacci(0) which equals 0

Spoiler if (count === 0) return 0;

But the provided tests doesn't check for this case, so a student can implement the fibonacci function by using the following logic:

if (n===1 || n===2) return 1;

and it would pass all the tests.

That's why I think a test for fibonacci(0) is necessary.

2. Acceptance Criteria:

  • Add a check for fibonacci(0)

helloWorld exercise test failes!

helloWorld.js file:

const helloWorld = function() {
  return 'Hello, World!'
};

module.exports = helloWorld;

helloWorld.spec.js file:

const helloWorld = require('./helloWorld').default;

describe('Hello World', function() {
  test('says "Hello, World!"', function() {
    expect(helloWorld()).toEqual('Hello, World!');
  });
});

when i run the test it tells me it fails anyways:

> [email protected] test
> jest "helloWorld.spec.js"

 FAIL  helloWorld/helloWorld.spec.js
  Hello World
    ✕ says "Hello, World!" (2 ms)

  ● Hello World › says "Hello, World!"

    TypeError: helloWorld is not a function

      3 | describe('Hello World', function() {
      4 |   test('says "Hello, World!"', function() {
    > 5 |     expect(helloWorld()).toEqual('Hello, World!');
        |            ^
      6 |   });
      7 | });
      8 |

      at Object.<anonymous> (helloWorld/helloWorld.spec.js:5:12)

Feature: Split out exercises by lesson

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Feature Request:

  • Learners get occasionally confused about whether or not they should do all the exercises in the repository, or only the ones assigned (because in the second case, whats the point for the other exercises). A easy way to alleviate this would be to split the exercises out per lesson, and then put them in a separate folder per said lesson (so eg the first seven would go into /fundamentals-part-4/, and the rest into /fundamentals-part-5/). We could then update the curriculum links to point to those folders

2. Acceptance Criteria:
[ ] the exercises are separated out by lesson
[ ] the curriculum has been updated to account for these changes

3. Additional Information:

../javascript-exercises/caesar/caesar.readme supplemental reading/video provision needed

I noticed the Caesar Cipher assignment has a lot of new concepts being introduced without any introductory information being provided in correlation to unicode or regex.

When googling these topics as a beginner the results are either too technically complex or addressing matters unrelated to the cipher task.
For unicode I read this to comprehend it, however, this might be more succinct and suffice.

For the ruleset to ignore punctuation and spacing I learnt about the RegEx, I saw other students making lists with the alphabet to then loop through whether each iterated element corresponded to their personal list. This 20 minute video might be useful long term for students to learn during this lesson, perhaps even the assignments prior to it as it would come in handy during the palindrome task as well. The first 10 minutes will be sufficient to complete the task. This also makes you less dependant on random code from stackoverflow without knowing what it actually does.

Caesar

Expected answer for the below test is incorrect.

xit('works with large negative shift factors', function() {
expect(caesar('Hello, World!', -29)).toEqual('Ebiil, Tloia!');

Correct answer should be 'Ebiil, Tloia!'

Edit: This is not an issue. My understanding was not correct.
Please close this issue.

NPM Vulnerabilities Warning

After running npm install as directed in the readme, I was shown a 'vulnerability' warning.
Screenshot from 2022-05-14 13-46-42

From what I can gather, I'm supposed to ignore these. However, a 'critical' warning implies that it should be attended to.

Since this is the first use of npm install in the course, maybe it would be a good idea to add a mention of the audit feature the readme?

"zsh: command not found: ___ " issues

Hey, I just started these exercise that require Jasmine and I am getting the error "zsh: command not found: jasmine", when I try to run the "jasmine helloWorld.spec.js" command.

I went through the entire process of installing nvm / node multiple times and they seemed to install properly because I can see the latest versions when I try to enter it in the terminal.

Everything seems to run fine when I go through the entire installation process written in the README file, but if I try to run jasmine or nvm/npm/node at another time I run into the "zsh: command not found" issue.

If I try to run "npm install jasmine -g", "npm install -g jasmine", "npm install jasmine-node -g", etc. again, I get "zsh: command not found: npm" again.

I added "source ~/.bashrc" to my bash profile but I am still experiencing the same "zsh: command not found" issues when I try to run jasmine/npm/nvm/node.

Do any of you know what could be causing this and how to fix it? (I am on MacOS 10.15.5 if that helps)

repeatString test should check for random inputs

In this test a new test should be added that inputs random numbers to help prevent hard-coding solutions.

There should also be some comments explaining the random number generation.

One should use regex to verify the return value of repeatString called with a random input. Regex should be used to prevent giving away a solution.

A solution for the regex is below:

"function return value".match(/((hey))/).length === random number

This is for first-time contributors only

removeFromArray

I've observed that the solutions delete all occurrences. This should be a requirement in the readme or spec file.

javascript-exercises/solutions/sumAll - order of exception checks

Looking at the solution file for sumAll, shouldn't the exception check for the typeof the inputs be done before checking if the inputs are greater than 0?

For example, if the user passes in sumAll("-1", 2) and the exception check to see if they are both above 0 is done first, the exception may not check it correctly. Checking the typeof each to ensure they are both numbers before making sure they are both positive would flow more logically.

Add something to make the student learn and study "Rest Parameters"

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Feature Request:
The 04_removeFromArray exercise is good but the rest parameter that is needed is not being called or said to be learnt.

2. Acceptance Criteria:

3. Additional Information:

Bug - 04_removeFromArray: missing test case

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Bug:

The testing for the solution has a missing test case that looks into if all the elements in the Array that matches the element to be deleted is properly deleted.

In other words, the Array from which the elements are supposed to be deleted from has no repeating values. So, the test case does not directly prompt the user to write code that deletes all the instances of the element that is supposed to be deleted from the Array.

2. How To Reproduce:

  • Write the code that satisfies all the 7 cases in the 04_removeFromArray exercise.
  • Open the `removeFromArray.spec.js` file and modify the 5th test case such that the initial array has [1, 2, 2, 3, 4]
  • Run the code again.

3. Expected Behavior:

If the code written does not account for repeated values like the one below, the modified test case (5th test case) results to a failure.

const removeFromArray = function(...arg) {
    const arr = arg[0];
    arg.splice(0,1);

    for (let i = 0; i < arg.length; i++) {
        for (let j = 0; j < arr.length; j++) {
            if (arg[i] === arr[j]) {
                arr.splice(j, 1);
                // j--;
            }
        }
    }

    return arr;
};

Note: Line 9 is commented such that the test case is not matched!

4. Desktop/Device:

  • Device:
  • OS:
  • Browser:
  • Version:

5. Additional Information:

Exercises : Change CommonJS to ESmodule format

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Feature Request:

  • Currently the exercises are using CommonJs format. i.e module.exports
  • Could be changed to ESmodule format. i.e export default

2. Acceptance Criteria:

3. Additional Information:

A friendly suggestion: we should simplify the unit test for Exercises 01 ~ 07.

Since Exercises 01 ~ 07 are faced to beginners. They are not supposed to use a real-world unit test framework.
To install Jest, you have to install a bunch of nvm, node.js, npm at first. And they have to clone the whole repo, which include critical package.json and pack-lock.json that unit test depends on. If they just copy helloWorld.js and helloWorld.spec.js file, it doesn't work.

Although I'm an experienced back-end developer, and have been work with Java JUnit for years, it spent me a few hours to install these tools and to figure out how npm work with Jest via package.json and pack-lock.json.

My suggestion is to give them some independent handmade unit test script, for example,

const helloWorld = require('./helloWorld');

function describe(lable, body) {
  console.log(lable);
  body();
}

function test(label, body) {
  if (!body()) console.log(`Failed: ${label}`);
}

describe('Hello World', () => {
  test('says "Hello, World!"', () => {
    expect(helloWorld()).toEqual('Hello, World!');
  });
});

Only 2 files helloWorld.js and helloWorld.spec.js are required, and can be run with

node helloWorld.spec.js

It can give them an idea of what is unit test actually is, and they will not be scared.

Clarifying test functions should meet multiple test requirements

I'm suggesting a note after this line: 'After you pass your first 'it', you will change the next 'xit' to an 'it' and test your code again. You'll do this until all conditions are satisfied.' For clarities sake, this means that at the end of each lesson, the single function should satisfy all of the jasmine test requirements at once.

This could totally be a comprehension issue for me (I'm an artist and English is just barely my first language), but on my first read through I thought I needed to pass all it tests separately, and even tried to rewrite the test itself for different functions.

Thankfully a friend of mine who is a programmer (I've been having him review things as I finish them) explained it to me and it all clicked. I re-read the intro's to see if I was just distracted or not comprehending the README. I think that is primarily the case, just figured this addition might help save someone else the same confusion.

You all rock and thanks for providing/maintaining this material! I've learned far more from these courses than any other source on the net.

tempConversion spec doesn't support destructuring

It seems like Jasmine doesn't support the syntax:

const {ftoc, ctof} = require (./tempConversion)

When trying to test my code, I got a syntax error for the opening {

Changing the syntax to the following fixed the issue:

const helpers = require('./tempConversion')
const ftoc = helpers.ftoc
const ctof = helpers.ctof

Shift testing library to Jest from Jasmine

Using a global install of Jasmine is unnecessary because our curriculum doesn't point back to it, and instead points towards libraries like Jest. The process could be simplified for new learners who don't need to rely on a global install and can instead easily just run npm test. The failure/successes of each test is also more verbose with Jest by default, which will make new learners more easily know when they are on the right track.

Completion Criteria:

  • Jasmine is removed as a dependency
  • Jest is added as a local dependency
  • README is rewritten, as well as all other markdown files mentioning Jasmine
  • Test syntax is updated from Jasmine to Jest syntax
  • All tests in the solutions branch pass

Fundamentals Part 2, Exercise 3: Instructions Rewrite

  • I have thoroughly read and understand The Odin Project Contributing Guide

  • The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ

  • I would like to be assigned this issue to work on it


1. Description of the Feature Request:
The instructions for math.js are easily misinterpreted:

* Some rules first:
 *   Enter the operations, replacing the `"?"`, make the computer do the work for you. 
 *   Do not manually enter the answer, for example: "one plus ten" would look like 1+10

Namely, "Do not manually enter the answer, for example..." Grammatically, what follows "for example" is manually entered content that is not permissible. Please rework to indicate that the exercise does need a solution that would like like 1+10...

Otherwise, the instructions ask us to provide an operator without operands (the "?" is one character, the student expecting to provide one character only to replace it), which, with the provided code, will not ever produce the correct / desired solution.

2. Acceptance Criteria:

  • Instructions do not discourage and encourage in the same line
  • Updated instructions are pushed to Replit

3. Additional Information:
Lesson: https://www.theodinproject.com/lessons/foundations-fundamentals-part-2
Replit: https://replit.com/@OdinProject/lets-do-some-math#math.js

what is Jasmine

I don't have jasmine, how do I run it at the command line? Should be explaine in the readme

Snakecase solution is problematic

The snakecase solution ignores the possibility of a word without spaces having multiple upper case characters that should not be separated with an underscore. For example "SnakECase" does not pass.

Just a minor quibble. I love the course!

Update repeatString to take alternative strings in tests

To help avoid students hard coding certain elements of the function, the tests should be updated to pass in a different string for each individual test instead of each test passing in "hey".

Completion Criteria:

  • Each test in repeatString.spec.js has its own unique string that it passes in eg: repeatString(10, "hello"); repeatString(5, "goodbye")
  • The expect() is updated to reflect this new string
  • Test passes
  • solutions and main branch both have these changes

Unit test for 08_calculator power() function is too weak.

Only one test case for power() function is not enough,

expect(calculator.power(4,3)).toBe(64); 

I add more unit tests:

  1. tests with negative base.
  2. tests for the negative exponent.
  3. if exponent equals 0, result should always be 1.
    3.1. except for a base of 0, which should return 0.
  4. if base equals 0,
    4.1. return Infinity if exponent is negative.
    4.2. otherwise, always return 0.

Here is my pull request: #223 08_calculator: add some unit test.
And to keep solutions up to date, watch this pull request: #226 Keep calculator solution up to date

Bug - Exercises : Test expecting wrong result & typo found

Complete the following REQUIRED checkboxes:

  • [x ] I have thoroughly read and understand The Odin Project Contributing Guide
  • [x ] The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • [ x] I would like to be assigned this issue to work on it

1. Description of the Bug:

Within exercise 12 (./12_findTheOldest/findTheOldest.spec.js), the second test states, "finds the oldest person if someone is still living"
The expected result is, "Ray". But Ray's yearOfDeath is: 2011. Meaning the test should expect, "Carly", because Carly is the only person without a yearOfDeath stated, making Carly the "oldest person if someone is still living" as stated in the test requirements.

Additionally, the third test data set states Carly's yearOfBirth to be 1066, when it should read as 2018.

2. How To Reproduce:

  1. Navigate to exercise 12, file: findTheOldest.spec.js
  2. line 41 shows the incorrect expected result as 'Ray'
  3. line 47 shows the yearOfBirth typo

3. Expected Behavior:

  1. line 41 should state 'Carly' as the expected result
  2. line 47 should reflect yearOfBirth as 2018, and not 1066

4. Desktop/Device:

N/A

5. Additional Information:

This is my first bug report on Github and I believe I met all the required criteria. I apologize in advance if I mistakenly overlooked anything. I assure you it was not intended.

Thank you!

Generator exercise - README should note that the exercise isn't one for a student to complete

I was working through the javascript exercises from Web Development 101
FUNDAMENTALS PART 4
not paying attention to the actual list on the page, and accidentally did all of them including the beginning of the generator exercise, not realizing it wasn't even for students until part of the installation instructions didn't work.

I googled and found [forum post](this https://forum.theodinproject.com/t/wd101-fundamentals-part-4-unable-to-install-generator-exercise-also-huh/2386) explaining it was only for the maintainers:

The generator exercise is not actually an exercise… it is a script that generates exercises. I was using it when I wrote them so I didn’t have to hack out the same boilerplate code every time I wrote a new one.

I'm adding the issue here as a reminder for someone to add the note to the README file for the exercise. If you are Ok with it, I could take a stab at making the note and putting in a pull request.

Bug - : 05_sumALL: Returning ERROR with negative numbers

Complete the following REQUIRED checkboxes:

  • [ o] I have thoroughly read and understand The Odin Project Contributing Guide
  • [ o] The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Bug:
The 4th test for this task checks that the function returns ERROR with negative numbers. However, the question did not state that the integers had to be non-negative, and it is in fact possible to obtain a proper answer even with negative numbers.

2. How To Reproduce:

  1. Code without error checking for negative numbers.
  2. 4th test fails

3. Expected Behavior:

  1. Code without error checking for negative numbers.
  2. 4th test should pass, with an answer of -45

4. Desktop/Device:

  • Device: Virtual Machine
  • OS: Ubuntu
  • Browser: NIL
  • Version: NIL

5. Additional Information:

leapYears README.md

Complete the following REQUIRED checkboxes:

  • [X ] I have thoroughly read and understand The Odin Project Contributing Guide
  • [X ] The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ

The following checkbox is OPTIONAL:

  • [X ] I would like to be assigned this issue to work on it

1. Description of the Feature Request:
The description of what constitutes a leap year in the exercise 06 README.md file could be better worded. I found this description of leap years more straight forward "In our calendar (Gregorian) a leap year is a year which is both evenly divisible by 4 and not divisible by 100 or is evenly divisible by 400."

Source: https://www.calendar-12.com/leap_year

2. Acceptance Criteria:

  • README.md file updated with new/additional description of leap years
  • (optional) remove previous description

3. Additional Information:
I realize it could have just been me that was confused by this but, as soon as I looked up another definition for leap years I could understand the logic much better and my code passed all the test cases.

JavaScript terminal

Hello, under helloWorld project the README.md says: "Go ahead and run the tests by entering jasmine helloWorld.spec.js in the terminal and watch it fail." I use Visual Studio Code with Windows 10, how am I supposed to do this, why is there no guide on setting up the environment? Thank you.

npm install -g jasmine

npm install -g jasmine leads to the following errors for me:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Should it be run as sudo?

Bug - 13_caesar: Test results appear correct but Fail

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Bug:

Running the tests on my code results in results that seem to pass but are counted as fail.

image

2. How To Reproduce:

This is my code for the project:

const caesar = function(string, shiftValue) {
    let encodedString = "";
    for (let index = 0; index < string.length + 1; index++) {
        let letterUnicode = string.charCodeAt(index);
        if (letterUnicode >= 65 && letterUnicode <= 90){ // Capital letters
            letterUnicode += shiftValue;
            while (letterUnicode >90){ // Deal with overlapping into other unicodes
                letterUnicode -= 26;
            } 
            while (letterUnicode <65){
                letterUnicode += 26;
            }
        }    
        else if(letterUnicode >= 97 && letterUnicode <= 122){ // Lowercase letters
            letterUnicode += shiftValue;
            while (letterUnicode > 122){ // Deal with overlapping into other unicodes
                letterUnicode -= 26;
            }
            while (letterUnicode < 97){
                letterUnicode += 26;
            }
        }
        encodedString += String.fromCharCode(letterUnicode);
    }
    return encodedString;
};

3. Expected Behavior:

The tests results for all of the tests appear correct, but they all fail. I haven't modified the .spec.js file in any way other than removing .skip from all the tests.

Haven't seen this kind of issue with the previous exercises.

4. Desktop/Device:

  • Device: Lenovo Laptop
  • OS: Windows 10
  • Node version: v18.12.1
  • Jest version: 8.19.2

5. Additional Information:

I'm wondering if there's some quirk to the fromCharCode method. Maybe there are some invisible characters being added. Or perhaps the terminal is hiding something and making the results appear identical when they are actually different in some way.

Simon says

I noticed that the Simon says exercise was removed from the solutions branch awhile back. I also saw that it is still on the master branch however. I did most of the exercise myself, all the way to the last two specs.

"doesn't capitalize 'little words' in a title", <-- This spec and the one directly after it seemed a bit out of place. They also seem very general and without a great short solution using native js. "little words" just feels subjective and out of scope with the rest of the fairly concise exercise.

Possible options bellow: (I would be happy to make them if you would like)

  1. Remove the last two specs from Simon_says on the master branch and Add solutions to the solutions branch.
  2. Remove Simon_says from completely from Master and update TOP main curriculum repo.
    https://www.theodinproject.com/courses/web-development-101/lessons/fundamentals-part-5

On a side note I also noticed that Listed in the solutions branch is probably a throwaway file for node_modules.

the sumAll exercise solution code

It's a simple request. Please assist with commenting solution code for better understanding of the solutions. For instance the sumAll exercise solution has no step by step explanations which will be very helpful. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.