Giter Site home page Giter Site logo

javascript-core-1-coursework-week1's Introduction

Coursework

Like learning a musical instrument, programming requires daily practice.

The exercises are split into two folders: mandatory and extra. All homework in the mandatory section must be completed for homework by the following lesson.

The extra folder contains exercises that you can complete to challenge yourself, but are not required for the following lesson.

If you think you need to do more practice with the basics, then you can find some more exercises listed in resources.md. These exercises are not mandatory and won't be assigned as part of your coursework for the week.

Setting up your code editor

There are some tools that will help you to write code. One of these, Prettier, formats your code, making it easier for you and others to read.

1. Install prettier

2. Enable formatting on save

Running the code/tests

The files for the mandatory/extra exercises are intended to be run as jest tests.

  • Once you have cloned the repository, run npm install once in the terminal to install jest (and any necessary dependencies).
  • To run the tests for all mandatory/extra exercises, run npm test
  • To run only the tests for the mandatory exercises, run npm test -- --selectProjects mandatory
  • To run only the tests for the extra exercises, run npm test -- --selectProjects extra
  • To run a single exercise/test (for example mandatory/1-writer.js), run npm test -- --testPathPattern mandatory/1-writer.js (Remember, you can use tab-completion to get files relative to the current directory, so mTab ↹/1-Tab ↹ will autocomplete get you the test file starting with 1-)

For more information about tests, look here:

https://syllabus.codeyourfuture.io/guides/intro-to-tests

Try out variant way of running tests:

  • npm test -> run all mandatory and extra tests
  • npm test -- --selectProjects mandatory -> run only mandatory tests
  • npm test -- --testPathPattern mandatory/1-syntax-errors.js -> run single test

Solutions

The solutions for this coursework can be found here:

https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1-Solution

This is a private repository. Please request access from your Teachers, Buddy or City Coordinator after the start of your next lesson.

Instructions for submission

For your homework, we'll be using tests to check your answers. The tests will assert that your functions behave in the correct way. A failing test ❌ indicates that a function is not behaving correctly; a passing test ✅ indicates that your function is behaving correctly.

  1. Complete the challenges in each file and save it once you're happy with your changes
  2. Run the script to check the results against the tests - all tests should read PASSED if you completed the challenges correctly. If a test reads FAILED, find the associated test to identify which function failed and fix it.
  3. Raise a PR once you're happy with the quality of your code

javascript-core-1-coursework-week1's People

Contributors

chrisowen101 avatar dedekind561 avatar gregdyke avatar illicitonion avatar lpmi-13 avatar mike-shields-cyf avatar moneyinthesky avatar nholdsworth94 avatar sallymcgrath avatar samiwmg avatar

Stargazers

 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  avatar

javascript-core-1-coursework-week1's Issues

Tests need to be reviewed on mandatory folder - exercise 4-tax

On the first function, it asks you to calculate the tax (e.g. if you want to put a 20% sales tax on top of a coat priced at £80, the sales tax is £16), but the tests are expecting you to provide the full price: original price plus sales tax (e.g. 80 + 16 = 96). The second function then asks you to utilise the information from the calculate tax function to get the full price (original price plus tax to be added on top).

Minor tweaks to instructions

  • Update to the directory needed to cd into for the Hello World exercise
  • Update the test commands needed to run some of the extra exercises in the repo

extra 8 ball jest test have error

I believe there is something wrong with the extra 8 ball test part.
when I run it with the same code in a separate file with out jest test it runs fine and gave me the four moods ( very positive, positive , ... ) but with the jest test on the file it prints out the log file with numbers instead of the moods.


npm WARN config global --global, --local are deprecated. Use --location=global instead.

[email protected] test
jest "--testPathPattern" ".\extra\3-magic-8-ball.js"

FAIL extra extra/3-magic-8-ball.js
× whole magic 8 ball sequence (21 ms)
√ magic 8 ball returns different values each time (23 ms)
× checkAnswer works for It is decidedly so. (3 ms)
× checkAnswer works for My reply is no. (2 ms)

● whole magic 8 ball sequence

expect(jest.fn()).toHaveBeenCalledTimes(expected)

Expected number of calls: 1
Received number of calls: 3

  130 |   expect(typeof answer).toEqual("string");
  131 |
> 132 |   expect(consoleLogSpy).toHaveBeenCalledTimes(1);
      |                         ^
  133 |   expect(consoleLogSpy).toHaveBeenLastCalledWith("The ball has shaken!");
  134 |
  135 |   expect(checkAnswer(answer)).toBeOneOf([

  at Object.<anonymous> (extra/3-magic-8-ball.js:132:25)

● checkAnswer works for It is decidedly so.

expect(received).toEqual(expected) // deep equality

Expected: "very positive"
Received: "l"

  163 |
  164 | test("checkAnswer works for `It is decidedly so.`", () => {
> 165 |   expect(checkAnswer("It is decidedly so.")).toEqual("very positive");
      |                                              ^
  166 | });
  167 |
  168 | test("checkAnswer works for `My reply is no.`", () => {

  at Object.<anonymous> (extra/3-magic-8-ball.js:165:46)

● checkAnswer works for My reply is no.

expect(received).toEqual(expected) // deep equality

Expected: "very negative"
Received: " "

  167 |
  168 | test("checkAnswer works for `My reply is no.`", () => {
> 169 |   expect(checkAnswer("My reply is no.")).toEqual("very negative");
      |                                          ^
  170 | });
  171 |

  at Object.<anonymous> (extra/3-magic-8-ball.js:169:42)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Without a doubt.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : negative

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Better not tell you now.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Yes - definitely.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
As I see it, yes.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very negative

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Don't count on it.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very negative

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
My reply is no.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Yes - definitely.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
It is certain.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Outlook good.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very positive

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
Yes - definitely.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The ball has shaken!

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : very negative

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
My reply is no.

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : 0

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)
      at Array.map (<anonymous>)

console.log
The answer is : 11

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)
      at Array.map (<anonymous>)

console.log
The answer is : 2

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)
      at Array.map (<anonymous>)

console.log
The answer is : 15

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)
      at Array.map (<anonymous>)

console.log
The answer is : 7

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)
      at Array.map (<anonymous>)

console.log
The answer is : 12

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)
      at Array.map (<anonymous>)

console.log
The answer is : 9

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

console.log
The answer is : 13
at console. (node_modules/jest-mock/build/index.js:845:25)

console.log

  at console.<anonymous> (node_modules/jest-mock/build/index.js:845:25)

Tests: 3 failed, 1 passed, 4 total
Snapshots: 0 total
Time: 1.315 s


when i ran the same program on a saparate file with for loop in 1000 intervals it gave me the moods right.
The answer is : very positive
The answer is : negative
The answer is : very negative
The answer is : negative
The answer is : very negative
The answer is : very negative
The answer is : very negative
The answer is : positive
The answer is : negative
The answer is : positive
The answer is : very positive
The answer is : very negative
The answer is : very positive
The answer is : negative
The answer is : positive
The answer is : very negative
The answer is : positive
The answer is : very negative
The answer is : very positive
The answer is : very positive
The answer is : very positive
The answer is : positive
The answer is : positive
The answer is : very positive
The answer is : very negative
The answer is : very positive
The answer is : negative
The answer is : very positive
The answer is : very negative

Builds are failing on the run extra-tests check.

Builds are failing on the run extra-steps Action.

Possibly related to Open issue #224

Example build output

`Run npm run extra-tests
npm ERR! Missing script: "extra-tests"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run

npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/logs/2022-08-01T12_1545_428Z-debug-0.log
Error: Process completed with exit code 1.`

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.