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

NW4-Haliema Adiem-Javascript-core1-coursework-week1 - #178

Closed
Haliema26 wants to merge 2 commits into
CodeYourFuture:masterfrom
Haliema26:master
Closed

NW4-Haliema Adiem-Javascript-core1-coursework-week1#178
Haliema26 wants to merge 2 commits into
CodeYourFuture:masterfrom
Haliema26:master

Conversation

@Haliema26

Copy link
Copy Markdown

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: Haliema Adiem
  • Your City: Northwest class
  • Your Slack Name: Haliema

Homework Details

  • Module: Javascript
  • Week: 1

Notes

  • What did you find easy?

  • some parts of the exercise task

  • What did you find hard?

  • The Mandatory task

  • What do you still not understand?

  • still confused about the different styles of writing functions.

  • find it hard sometimes to draw a plan for my answer before starting answering the questions directly.

  • Any other notes?

@SteveLeicester

Copy link
Copy Markdown

Great to see this Haliema. All the exercises seem fine and work apart from L-functions-nested. Well actually your L-function-nested does give the expected output. But take care to follow the instructions.

So we are asked to include a function that spells the name in uppercase

Lets do this - and call it shoutyName

function shoutyName(person){
return person.toUpperCase();
}

We are also asked to make a shouty greeting which will be "HELLO", So we get

function shoutyGreeting(person){
var greeting = "HELLO ";

/* Now we can call the shoutyName function from within this function. */
return greeting + shoutyName(person);
}

Then run the functions

console.log(shoutyGreeting(mentor1));
console.log(shoutyGreeting(mentor2));
console.log(shoutyGreeting(mentor3));
console.log(shoutyGreeting(mentor4));
console.log(shoutyGreeting(mentor5));

Can you think of an advantage of doing this compared to your way? Both give the same result so your customer will be happy with the software you provided.

What if the customer said can you change the greeting to "HELLO, HOW NICE TO SEE YOU ". How many lines of code will you have to change compared to the above nested function approach.

Perhaps your customer wont mind but if there are thousands of lines of code and a change needs to be made it can make a huge difference to how long the customer will get the new software who may no longer be happy to hear that.

But the key take away is to follow the instructions. Oh and to ask if the instructions don't make sense.

Now - on to the mandatory work. Now I know you said you found these hard but great that you had a go. Did you manage to run the tests using jest?

Be careful when concatenating strings

var string1 = "hello"
var string2 = "Haliema"
var string3 = string1 + string2 /*Leaves no space so check whether you need to ensure there is a gap between strings */

The test fails as follows

Expected: "Hello, my name is Sonjide and I am 27 years old"
Received: "Hello, my name is Sonjide and I am 27years old"

Its only a minor thing but just to say be careful when joining strings.

The other thing which is important - TTD. Test Driven Development. The idea is that a test tells you what the function should do. Its like the instructions and so important to look at the tests then write a function to pass the test.

test("getTotal returns a string describing the total", () => {
expect(getTotal(23, 5)).toEqual("The total is 28");
});

So getTotal returns a string describing the total - this is very important.

So lets make the function to do just that.

function getTotal(a, b){
var sum = a + b;
/* We have the sum - so make a description */
return "The total is " + sum;
}

So if you look at the tests - they are telling you what to do

Note there are similar space problems with concat function in 3-function-output. So yes care with space between concatenated strings. See what the expected result is "code_space_your_space_future".

test("concatenate example #1", () => {
expect(concatenate("code", "your", "future")).toEqual("code your future");
});

Hopefully looking at the tests will help to make the tasks more straight forward.

But this is a good effort and I think the most important thing is to take care with the instructions, study the tests for TTD and make a function to pass those tests (for the mandatory exercises).

Keep it going Haliema.

Steve

@Haliema26

Haliema26 commented Jul 26, 2021

Copy link
Copy Markdown
Author

Thanks🙂, @SteveLeicester, I can see more broadly now. I have to put on my account the simplicity, and it is implemented in the fewer lines of coding. similarly, I have to consider getting back to my code later either for debugging or adding new features and then this is the job of the developer.

@github-actions

github-actions Bot commented Sep 7, 2021

Copy link
Copy Markdown

Your coursework submission has been closed because nobody has interacted with it in six weeks. You are welcome to re-open it to get more feedback.

@github-actions github-actions Bot added the Stale label Sep 7, 2021
@github-actions github-actions Bot closed this Sep 7, 2021
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.

2 participants