Skip to content

Conversation

@kohanman
Copy link

@kohanman kohanman commented Nov 1, 2025

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

done all sprint 2 coursework for Structuring and testing data Module

Questions

n/a

@kohanman kohanman added 🐇 Size Small Around an hour 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Nov 1, 2025

function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
var str = `${str[0].toUpperCase()}${str.slice(1)}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

str (the parameter) works like a local variable.
Redeclaring str using var has no effect on str (Note: Redeclaring str using let or const is prohibited)

So

var str = `${str[0].toUpperCase()}${str.slice(1)}`;

is identical to

str = `${str[0].toUpperCase()}${str.slice(1)}`;

In general, avoid using var because it can make our code behave in unexpected ways (if not used properly); let and const are safer.

.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0");

console.log(${pounds}.${pence}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

The function is expected to return a string in pound format. Outputting the string to console is not the same as returning the string.


// c) What is the return value of pad is called for the first time?
// =============> write your answer here
//00
Copy link
Contributor

Choose a reason for hiding this comment

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

To more precisely express a value is a string, we can enclose the value by a pair of double quotes. For example, "00".

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 🐇 Size Small Around an hour 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants