Giter VIP home page Giter VIP logo

assignments's People

Contributors

hkirat avatar lokesh3097 avatar me-imfhd avatar sahilsuman933 avatar sainith123 avatar siddanth-6365 avatar sidxh avatar siinghd avatar tarunclub 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  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

assignments's Issues

Test for Week-3/02-jwt behaving different than expected

In the test for function decodeJwt we need to return the decoded payload of the JWT if the token is valid as mentioned in the comment, but the test expect the output to be true instead of the decoded payload

image

Test file for this function
image

Issue in anagram test case

The existing test cases for the anagram function have inaccuracies in their expected output.

Existing Behaviour: The test case is set to true for the inputs of ('rail safety', 'fairy tales')

Solution : It should be set to false as they are not anagrams

In /01-js/tests/ directory run npx jest anagram.test.js .

Correction of countVowels Function Test Cases

Issue Description:

The existing test cases for the countVowels function have inconsistencies and inaccuracies in their expected outputs. These issues impact the accuracy and reliability of the function. Here are the identified problems in the test cases along with proposed fixes:

Inaccurate Counting:

  • Existing Behavior: The test cases for specific strings ('programming', 'OpenAI', 'chatbot', 'EaSiEr') produce incorrect counts for vowels.
  • Proposed Fix: Update the test cases to ensure the correct count of vowels is verified in these strings.

Steps to test:

In /01-js/tests/ directory run npx jest countVowels.test.js .

setup issue in mac m1 machine

Hi @hkirat,
I found following issue while running node for the first time in my mac m1 box.

**root ~/self_help/js_practice/assignments [master] $ npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/jee/self_help/js_practice/assignments/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/jee/self_help/js_practice/assignments/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: /Users/jee/.npm/_logs/2023-12-04T07_16_37_623Z-debug-0.log**

==> I was getting the above issue in my mac box and ran "npm init -y" to create package.json. Is it a right way to do that ?
==> But still I was facing some issue while running test. I think it was because I didnt have "jest" installed on my system.
==> Can u plz put some light on this issue ?

Fix Test Case for Calculator.js

By just checking if the expression contains /0 you could bypass test case for division by zero , which shouldn't' be the case because expression such as 10/(2-2) could also lead to division by zero.

#48

Assignment 01-js completed

Solved all the questions of Assignment 01-js:

Easy:

  • Anagram
  • Expenditure Analysis
  • Find Largest Element

Medium:

  • Count Vowels
  • Palindrome
  • Times

Hard:

  • Calculator
  • Todo List

problem in the tsconfig.json

i was doing the jwt assignment and I opened the tsconfig.json file in vscode.
i don't know if it's an error or not but vscode was showing this error message
No inputs were found in config file '/Users/sparshkarna/DevOps/assignments/week-3/02-jwt/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'.

image

unsed-var eslint error

Hey sir Can use "un-used-variables": false, to off the unused error caused by eslint rc file

Week3 02-jwt function comment description inaccurate

Small thing but in week-3/02-jwt/index.js the comment description for decodeJwt indicates the function is supposed to return an object or false. This is innacurate because based on the tests, the function is actually supposed to return true or false. Raising this since even though its a small issue, it can throw off students.

Unable to execute pull request

Github: When I created a pull request, I get:
Choose different branches or forks above to discuss and review changes. Learn about pull requests. I am unable execute a pull request. How to fix it?

Issue while setting up in Windows.

package.json file is missing!
when I ran npm install command from the 'assignments-master' directory,
it showed error, that's related to missing package.json.
image

I have tried the following in assignmensts-master/01-js directory and got these errors!
image

week-3 > 03-mongo > Readme.md | missing purchased property in Schema

ISSUE:
In the POST route while registering the user, it is not specified that the user should have a third property as purchased of type array. As the user purchases the course, it should have a purchased property set while signing up where all the purchases would be saved.

User Routes

GET: /users/purchasedCourses
Description: Lists all the courses purchased by the user. Input: Headers: { 'username': 'username', 'password': 'password' } Output: { purchasedCourses: [ { id: 1, title: 'course title', description: 'course description', price: 100, imageLink: 'https://linktoimage.com/', published: true }, ... ] }

POST: /users/signup
Description: Creates a new user account. Input: { username: 'user', password: 'pass' } Output: { message: 'User created successfully' }


SOLUTION:

USER SCHEMA should be:

const UserSchema = new mongoose.Schema({
// Schema definition here
username: String,
password: String,
purchased: Array,
});

&&

POST: /users/signup
Description: Creates a new user account. Input: { username: 'user', password: 'pass' }
newUser = {
username: req.headers.username,
password: req.headers.password,
purchased: [],
}
Output: { message: 'User created successfully' }

Fixed the issue in 1-promisify-setTimeout.test.js

Test cases of 1-promisify-setTimeout.test.js are not working because of async.

Used chatpgt to fix the test cases and now my code is working fine. To see the conversation with chatgpt click this link

This is the updated test file code👇️ please review it

const wait = require("../hard (promises)/1-promisify-setTimeout");

describe("wait function", () => {
  test("resolves after 1 second", async () => {
    const start = Date.now();
    await expect(wait(1000))
      .resolves.toBeUndefined(); // Wait for 1 second
    const end = Date.now();
    const difference = end - start;
    expect(difference).toBeGreaterThanOrEqual(1000); // Expect difference to be at least 1000 ms (1 second)
  }, 2000); // Set timeout to 2000 ms (2 seconds)

  test("resolves after 2 seconds", async () => {
    const start = Date.now();
    await expect(wait(2000))
      .resolves.toBeUndefined(); // Wait for 2 seconds
    const end = Date.now();
    const difference = end - start;
    expect(difference).toBeGreaterThanOrEqual(2000); // Expect difference to be at least 2000 ms (2 seconds)
  }, 3000); // Set timeout to 3000 ms (3 seconds)

  test("resolves after 3 seconds", async () => {
    const start = Date.now();
    await expect(wait(3000))
      .resolves.toBeUndefined(); // Wait for 3 seconds
    const end = Date.now();
    const difference = end - start;
    expect(difference).toBeGreaterThanOrEqual(3000); // Expect difference to be at least 3000 ms (3 seconds)
  }, 4000); // Set timeout to 4000 ms (4 seconds)
});

Issue in solution of week-3/04-mongo-with-jwt-auth assignment

week-3/04-mongo-with-jwt-auth/solution/middleware/admin.js
week-3/04-mongo-with-jwt-auth/solution/middleware/admin.js

In both the above mentioned files, the middleware just checks if the token is valid or not. However, it does not distinguish whether the token sent corresponds to a user or an admin. Consequently, a user can potentially access admin features by providing their token, and vice versa.

After token verification, the middleware should additionally validate whether the associated username belongs to an admin. If not, it should send an authentication failed error.

optimise bodyParser in week-02/03-mongo

it took a lot of time to figure out that when you include postman body and even if you comment it out the global middleware app.use(bodyaParser.json()) will try to parse and throw an error so set body to none or it should have nothig (not even commented something) while sending get requests or try to set bodyParser middleware after get routes. @hkirat is there any way to exclude a particular ruote from a global middleware

Enable adding labels in the PR

Currently we cannot add labels in the PR, this will help us a lot going ahead to differentiate PRs
can we enable that
image

Join() function not explained.

I think join() function which converts array into string is very important and should be included.If no one done it already allow mw to do it.

add a side popup bar in the video content

During watching the video content when i am spiliting the screen the video becomes small due to the side popup bar if you could implement the youtube like feature where when not required we can close the side popup bar

Typo fixes

There are few typo fixes in few of the README.md files for few of the week assignments

Fixed division test case for Calculator.js

JavaScript doesn't throw a regular error for division by zero, and instead returns Infinity or -Infinity, we need to adjust the test accordingly.

In this modification, the test checks if the result of the division by zero is equal to Infinity. This aligns with the behavior of JavaScript when dividing a number by zero.

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.