reading-notes

Reading 3 - HTML Lists, Control Flow with JS, and the CSS Box Model

HTML

Q1 When should you use an unordered list in your HTML document?

An unordered list should be used when the order of the list does not change the meaning.

Source

Q2 How do you change the bullet style of unordered list items?

The bullet style can be changed in CSS. For example, under the <ul>, you would put list-style-type: circle (or whatever shape.)

Source

Q3 When should you use an ordered list vs an unorder list in your HTML document?

An ordered list should be used for instructions and other things where the order can potentially change the meaning of the information.

Source

Q4 Describe two ways you can change the numbers on list items provided by an ordered list?

To change to numbers on the list, you can either add an attribute in the HTML doc that says <ol start="4"> if you wanted to start at 4. Alternatively, if you wanted to change the type of numbers used (for example, using Roman numerals), you could add the HTML attribute <ol type="I">

Source

CSS

Q5 Describe the CSS properties of margin and padding as characters in a story. What is their role in a story titled: “The Box Model”?

Margin defines the space between the border and other elements. The padding the space between the contents and the border. The box’s area is everything inside of the borders. The area of the box does not include what it in the margins.

Source

Q6 List and describe the four parts of an HTML elements box as referred to by the box model.

The box model is the width, height, padding, and margins elements.

Source

JavaScript

Q7 What data types can you store inside of an Array?

Any data type can be stored in an array. This includes strings, and numbers, as well as other arrays and objects.

Source

Q8 Is the people array a valid JavaScript array? If so, how can I access the values stored? If not, why?

const people = [[‘pete’, 32, ‘librarian’, null], [‘Smith’, 40, ‘accountant’, ‘fishing:hiking:rock_climbing’], [‘bill’, null, ‘artist’, null]];

The array is not valid beause of the ‘fishing:hiking:rock_climbing’ element. Colons can only be used in objects (I think) and underscores can’t be used.

Source

Q9 List five shorthand operators for assignment in javascript and describe what they do.

x += y adds y to x x *= y multiplies x by y x ** y takes x to the power of y x && y is a conditional that checks if both x and y are true x || y is a conditional that checks if either x or y are true

Source

Q10 Read the code below and evaluate the last expression and explain what the result would be and why.

let a = 10; let b = ‘dog’; let c = false;

// evaluate this (a + c) + b;

The result would be ‘10dog’ When 10 and false are added, the result (a + c) is just 10. When 10 is then added to ‘dog’, type coersion occurs and 10 becomes a string, which is then concatenated with ‘dog’

Source

Q11 Describe a real world example of when a conditional statement should be used in a JavaScript program.

A conditional statement could be used if you are checking to see if the user has input the correct answer, like we did in the labs. Once the correct answer is given, the next question is asked.

Q12 Give an example of when a Loop is useful in JavaScript.

A loop can be used when you want to do something to an entire array, or to an array until you reach a certain value. For example, if you are checking to see if an array contains a certain value, you could use a loop to go through an array and check for an exact match within the array.

Things I want to know more about

I want more practice using the CSS Box model. I feel like I get the idea, but putting it into practice is still foggy.