Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London-10-Afsha-Hossain-JavaScript-core-1-coursework-week1#503

Open
Afsha10 wants to merge 5 commits into
CodeYourFuture:masterfrom
Afsha10:master
Open

London-10-Afsha-Hossain-JavaScript-core-1-coursework-week1#503
Afsha10 wants to merge 5 commits into
CodeYourFuture:masterfrom
Afsha10:master

Conversation

@Afsha10
Copy link
Copy Markdown

@Afsha10 Afsha10 commented Feb 20, 2023

Completed the mandatory part and most of extras . Need help in the last task in extra.

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Completed the mandatory part and most of extras . Need help in the last task in extra.
@Afsha10 Afsha10 changed the title Completed the mandatory part and most of extras London-10-Afsha-Hossain-JavaScript-core-1-coursework-week1 Feb 20, 2023
Comment thread mandatory/1-syntax-errors.js
Comment thread mandatory/1-syntax-errors.js
Comment thread mandatory/2-logic-error.js
Comment thread mandatory/4-tax.js Outdated

function calculateSalesTax() {}
function calculateSalesTax(price) {
return 1.20 * price;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just be 1.2

Comment thread extra/3-magic-8-ball.js Outdated
];

function checkAnswer() {
if answer = "It is certain." || "It is decidedly so." || "Without a doubt." || "Yes - definitely." || "You may rely on it." {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between = and ===

Comment thread extra/3-magic-8-ball.js Outdated
];

function checkAnswer() {
if answer = "It is certain." || "It is decidedly so." || "Without a doubt." || "Yes - definitely." || "You may rely on it." {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check syntax of if loop. ex.

If (condition) {
return something
} if else (condition) {
return something
} else {
return
};

Comment thread extra/3-magic-8-ball.js Outdated
*/
function checkAnswer(answer) {

const answer = [
Copy link
Copy Markdown

@maxbmaapc maxbmaapc Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My advice, break answers array into four arrays with relevant name (arr positive[answers], negative[answers] and so on) and then join them into one using spread operator.

Comment thread extra/3-magic-8-ball.js Outdated
"Very doubtful."
];

function checkAnswer() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this function you need to compare each answer with location in certain array. But in your loop you compare the array itself with the possible answer, so it's not gonna work.

Comment thread extra/3-magic-8-ball.js Outdated
Comment on lines +50 to +51
answerRandom = Math.floor(Math.random() * 16);
return answerRandom;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
answerRandom = Math.floor(Math.random() * 16);
return answerRandom;
answerRandom = allAnswers[Math.floor(Math.random() * allAnswers.length)];
return answerRandom;

Here you get answerRandom from your array

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use console.log to meet the condition of one of comments This should log "The ball has shaken!"

Comment thread extra/3-magic-8-ball.js Outdated
Comment on lines +67 to +71
"It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
const veryPositive = [ "It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
]

This is as an example of a child array

Comment thread extra/3-magic-8-ball.js Outdated
"Outlook not so good.",
"Very doubtful."
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const allAnswers = [...veryPositive, ...positive, ans so on]

check how works spread operator

Comment thread extra/3-magic-8-ball.js Outdated
Comment on lines +90 to +91
if answer = "It is certain." || "It is decidedly so." || "Without a doubt." || "Yes - definitely." || "You may rely on it." {
return "The answer is very positive: ${randomAnswer}";
Copy link
Copy Markdown

@maxbmaapc maxbmaapc Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if answer = "It is certain." || "It is decidedly so." || "Without a doubt." || "Yes - definitely." || "You may rely on it." {
return "The answer is very positive: ${randomAnswer}";
if (veryPositive.includes(answer)) {
return "very positive"
} if else (positive.includes(answer)) {
return ....

you can continue yourself
I hope it's helpful. if you get stuck, write me in slack, or check my PR

Comment thread extra/1-currency-conversion.js Outdated

function convertToBRL() {}
function convertToBRL(price) {
price = price * 0.99 * 5.7;
Copy link
Copy Markdown

@SeyoungJoo SeyoungJoo Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. when declaring a variable, must use const or let, otherwise it becomes a global variable which can cause a bug.

  2. the variable name and parameter name should be different :)

Comment thread extra/2-piping.js Outdated
let goodCode =
const betterStartingValue = 2;
additionResult = betterStartingValue + 10;
multiplicationResult = additionResult * 2;
Copy link
Copy Markdown

@SeyoungJoo SeyoungJoo Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use const 🚀

const additionResult = betterStartingValue + 10;
const multiplicationResult = additionResult * 2;

…a few corrections based on the reviewers comments.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants