-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
age = age + 1; | ||
console.log(age); |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain a little bit please? |
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); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! 👍 |
There was a problem hiding this comment.
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 👍