Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NW6/Nohe-Tekelmariyam/Module-JS/week-1 #135

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion week-1/errors/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// trying to create an age variable and then reassign the value by 1

const age = 33;
var age = 33;

Choose a reason for hiding this comment

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

That's great you used var to declare the variable age 👍

age = age + 1;
console.log(age);
5 changes: 4 additions & 1 deletion week-1/errors/3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);
let stringNumber = cardNumber.toString();
const last4Digits =stringNumber.slice(-4);

// The last4Digits variable should store the last 4 digits of cardNumber
// However, the code isn't working
// Make and explain a prediction about why the code won't work

Choose a reason for hiding this comment

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

Nice one, you could add a little explanation of your prediction as well!

//
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
console.log(last4Digits);
5 changes: 3 additions & 2 deletions week-1/errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
const 12HourClockTime = "20:53";
const 24hourClockTime = "08:53";
const HourClockTime12 = "20:53";
const hourClockTime24 = "08:53";
//variable can not start with numer symbol

Choose a reason for hiding this comment

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

Well explained! However, the code in line 1 needs a bit more attention!

Copy link
Author

Choose a reason for hiding this comment

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

can you explain a little bit please?

2 changes: 2 additions & 0 deletions week-1/exercises/count.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ count = count + 1;

// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing
//in line 3 the variable count is increase by one.
nohetekelmariyam marked this conversation as resolved.
Show resolved Hide resolved
console.log(count)
10 changes: 7 additions & 3 deletions week-1/exercises/decimal.js
nohetekelmariyam marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

const num = 56.5467;

// You should look up Math functions for this exercise https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

// You should look up Math functions for this exercise
// Create a variable called wholeNumberPart and assign to it an expression that evaluates to 56 ( the whole number part of num )
var wholeNumberpart= Math.floor(num);
// Create a variable called decimalPart and assign to it an expression that evaluates to 0.5467 ( the decimal part of num )
var decimalpart= num-Math.floor(num);
// Create a variable called roundedNum and assign to it an expression that evaluates to 57 ( num rounded to the nearest whole number )

var rounded= Math.round(num);
// Log your variables to the console to check your answers
console.log(wholeNumberpart);
console.log(decimalpart);
console.log(rounded);
2 changes: 2 additions & 0 deletions week-1/exercises/initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ let lastName = "Johnson";

// Declare a variable called initials that stores the first character of each string in upper case to form the user's initials
// Log the variable in each case
var initials= `${firstName.charAt(0).toUpperCase()} ${middleName.charAt(0).toUpperCase()}${lastName.charAt(0).toUpperCase()}`;

Choose a reason for hiding this comment

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

You have used the correct methods. Just double-check the output. Can we make it look better?

Copy link
Author

Choose a reason for hiding this comment

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

what should i change do you think? to make look better?

console.log(initials)
4 changes: 4 additions & 0 deletions week-1/exercises/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ const base = filePath.slice(lastSlashIndex + 1);
console.log(`The base part of ${filePath} is ${base}`);

// Create a variable to store the dir part of the filePath variable
const dirpath= filePath.slice(0,-8);
console.log(dirpath);
console.log(base);
// Create a variable to store the ext part of the variable

Choose a reason for hiding this comment

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

Can you try to create a variable to store the ext part of the variable as well?

4 changes: 4 additions & 0 deletions week-1/exercises/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const maximum = 100;
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;

// In this exercise, you will need to work out what num represents?

// Try breaking down the expression and using documentation to explain what it means
// the num variable first find random number 1 up to 100 then round the number
// and multiplay by maximum -minimum and add one finally add minimum

Choose a reason for hiding this comment

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

That is right. Also, think about the reason and logic behind doing them and how it works to get what we intended.

// It will help to think about the order in which expressions are evaluated
// Try logging the value of num several times to build an idea of what the program is doing
console.log(num);
3 changes: 3 additions & 0 deletions week-1/explore/chrome.md

Choose a reason for hiding this comment

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

Perfect! 👍

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ In the Chrome console,
invoke the function `alert` with an input string of `"Hello world!"`;

What effect does calling the `alert` function have?
alert is small box at the top that display a text

Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`.

What effect does calling the `prompt` function have?
prompt is a dialog box that the propmts user for input
What is the return value of `prompt`?
ok or cancel