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

Turning in Week 0 Assignment #47

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion WEEK-0.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# This is practice!
# This is practice!

Follow the steps in the readme of this repo, or the instructions in the curriculum to get setup with a fork of this repo.

Answer this one question, then follow the instructions to submit your first assessment!

#### 1. What is one thing we did in class this week that helped you learn the most?

Honestly, today's GitHub lesson was amazing. I like approaching learning by dissecting processes into steps and then actually doing them.

I absolutely love using the terminal (Window's Command Prompt) to run programs and save file states, etc. I feel like an actual programmer now!
31 changes: 21 additions & 10 deletions Week-1.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
// 1. Write an anonymous function that takes one argument of type number and decides if that number is evenly divisble by three or not. If it is, print the number and "is divisible by three". If it is not, print that the number "is not divisble by three".
let byThree = function(num){
if(num%3===0){
console.log(`${num} is divisble by three`);
}else{
console.log(`${num} is not divisble by three`);
}
}

// 2. Write about yourself using an object. Include at least three properties of you and store your object in a variable with your name.
let andyGarrett = {coffeeNeed: "high", sweetHaircut: true, income: -14000}

// 3. Create an array with at least 4 items inside it. Show how to access two values from the array in two different ways.
let arrOfFour = [1,2,3,4];
console.log(arrOfFour[0]); //1
let [one,,,] = arrOfFour; //1

// 4. Have the function AlphabetSoup(str) take the "str" parameter being passed and return a string with the letters in alphabetical order (ie. hello becomes ehllo). Assume no numbers or punctuation symbols will not be included in the parameter.

// Input:"hooplah"
// Output:"ahhloop"

// 4. Have the function AlphabetSoup(str) take the "str" parameter being passed and return a string with the letters in alphabetical order (ie. hello becomes ehllo). Assume no numbers or punctuation symbols will not be included in the parameter.
function AlphabetSoup(str) {

// your code goes here

return str;
let strArr = str.split('').sort().join('')
return strArr;
}

// keep this function call here
// keep this function call here

AlphabetSoup(readline());
AlphabetSoup(readLine());

// 5. Given the arrays below, use a for loop to print one value from each array concatenated together. How would your code need to change to accomodate arrays of different lengths?

//This for loop is based on the idea that both arrays are the same length, so the loop needs to run for the same number of times for both arrays to print all their values. However, depending on the desired outcome, you could change the for loops validation to run for the lenght of the longer or shorter arrays by putting that array's name.length instead.

var nums = [1, 5, 88, 2, 5, 42, 57, 101]

var nouns = ["ducks", "telephone booth", "the enterprise", "robots", "amazon", "eraser", "zafod", "a"]

for(let i=0;i<nums.length;i++){
console.log(nums[i] + " " + nouns[i]);
}
// output of the first function should be: "1 ducks"
61 changes: 40 additions & 21 deletions Week-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,72 @@

These are potential interview questions. Try your best to answer each question on your own before looking up the answer online.

#### 1. Name all of the data types in Javascript, mark which are primitives.
#### 1. Name all of the data types in Javascript, mark which are primitives.

//Your Answer


1. string - primitives
2. number - primitives
3. undefined - primitives
4. boolean - primitives
5. null - primitives
6. char - primitives
7. objects - object
8. arrays - object

//Googled Answer
Boolean.
Null.
Undefined.
Number.
String.
Symbol (new in ECMAScript 6)


#### 2. Look at this Javascript and try to predict, what will the browser's console show?
#### 2. Look at this Javascript and try to predict, what will the browser's console show?

``` javascript

var text = 'outside';
function logIt(){
console.log(text);
var text = 'inside';
};
var text = 'outside';
function logIt(){
console.log(text);
var text = 'inside';
};

logIt();
logIt();

```

first Guess:


Then, past the code in your console and explain why you were right/wrong.
first Guess:
This function will log "inside" to the console. Even though the text variable is defined in the global scope first, the newly defined text variable is inside the function's scope and hoists itself to the top to run instead.

Then, past the code in your console and explain why you were right/wrong.
It looks like I was partially correct. The variable declaration does hoist itself to the top of the function's scope, but it doesn't take it's value with it. Therefore, at the time that text is console logged, it has been declared but not assigned a value.

#### 3. What is JSON? How does it relate to javascript objects?

//Your Answer
JSON is a basic language based on the concept of Javascript objects in that it stores information in a table-like format by using key value pairs so that it can be easily read by computer programs.

//Googled Answer
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.


#### 4. Describe a closure, what is it good for and how do you recognize one?

//Your Answer
A closure is a way of using scope to hide information. It does this by putting a function inside of another (or multiple), and it uses the inner function's local scope to create variables that are "hidden" from the outer functions because they can't see them. By doing this, you can protect data that you don't wish to be seen or changed.

//Googled Answer

Languages such as Java provide the ability to declare methods private, meaning that they can only be called by other methods in the same class.

JavaScript does not provide a native way of doing this, but it is possible to emulate private methods using closures. Private methods aren't just useful for restricting access to code: they also provide a powerful way of managing your global namespace, keeping non-essential methods from cluttering up the public interface to your code.

#### 5. What's the difference between =, ==, and === in JavaScript?

//Your Answer


= - One equal sign is the assignment operator. It is used to assign values to variables or functions.
== - Two equal signs symbolize a comparison of logic that will return either true or false. It is used to compare values in if statements and loops. It does not account for the variable's type.
=== - Three equal signs also symbolize comparison, but it also evaluates the variable's type. For instance, the string '2' and the number 2 would return true with two equal signs, but would return false with three.

//Googled Answer
Triple equal sign in javascript means equality without type coercion. For example: 1=="1" // true, automatic type coersion 1==="1" // false, not the same type. Three equal signs indicates both the value and type are equal.
29 changes: 20 additions & 9 deletions Week-2.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// 1. Write an anonymous function that takes one argument of type array and returns the contents of that array in reverse order.

// test array: var testCase = ["one", "two", "three", "four"]
//test array:
var testCase = ["one", "two", "three", "four"]

var reverseArray(list) {
// ... your code here
reverseArray = (list) => {
return list.reverse();
}

reverseArray(test)
console.log(reverseArray(testCase))

// expected output: ["four", "three", "two", "one"]

Expand All @@ -23,22 +24,32 @@ var bicycle = {
}

// Log the type of bicycle:
console.log()
console.log(bicycle.type)

// Log just the bell from the list of gear
console.log()
console.log(bicycle.gear[2])

// Log the correct PSI for the tires
console.log()
console.log(bicycle.wheels.specs[2])

// 3. Write a function that takes two arguments, a string and an individual letter. The function should return a count of how many times the letter appears in the string.

let countLetter = (string,letter) => {
let counter = 0;
for(let i=0;i<string.length;i++){
if(string[i]===letter){
counter++
}
}
return counter;
}

// examples:

countLetter("Hello World", "l")
console.log(countLetter("Hello World", "l"))

// should return => 3

countLetter("Hello World", "z")
console.log(countLetter("Hello World", "z"))

// should return => 0
85 changes: 46 additions & 39 deletions Week-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,74 @@
Try your best to answer each question on your own before looking up the answer online. Once you're done writing your first answer, you can google the question and write the best answer you find.

#### 1. How do you link a css file to your html page?

//Your Answer
You have to import it to the top of the html file.

//Googled Answer
Use the HTML <link> element to refer to an external CSS file.

#### 2. What is a css class? How do you use declare one in html? When should you use an id instead of a class?

//Your Answer

A CSS class is a way to link pieces of html together so that they can all be formatted the same way. To declare one, you add the class attribute to the html tag {class="className"}, and then reference it in the CSS file by putting a dot in front of the class name {.className {}}

//Googled Answer


#### 3. The class "heading-box" exists in our html file - write the css code that would:

##### 1) align this box to the center of its container,
##### 1) align this box to the center of its container,
##### 2) give it a black border that is 5px wide,
##### 3) make its text appear in the center of the box

.heading-box {
display: flexbox;
justify-contents: center;
align-items: center;
border: 5px solid black;
align-text: center;
}

#### 4. What is Bootstrap? Explain a few reasons that you might choose to use it in a project?

//Your Answer


//Googled Answer


#### 5. Name 4 semantic html tags.

#### 6. What is block scope that became available in ES6? Include how it differs from javascript's local and global scope, and what variables are block scoped.
#### 6. What is block scope that became available in ES6? Include how it differs from javascript's local and global scope, and what variables are block scoped.

//Your Answer


//Googled Answer

#### 7. What is front end development? Can you identify any tools/skills that are uniquely required of front end developers?

//Your Answer


//Googled Answer
#### 8. Choose one of the new ES6 concepts we learned about this week (namely: block scope, classes, and string interpolation) and write example code that demonstrates the concept, with comments to explain what is going on.
#### 9. What is the difference between a div and a span?


#### 8. Choose one of the new ES6 concepts we learned about this week (namely: block scope, classes, and string interpolation) and write example code that demonstrates the concept, with comments to explain what is going on.


#### 9. What is the difference between a div and a span?


//Your Answer


//Googled Answer


#### 10. How would you explain the idea of "inheritance" in object oriented programming?


//Your Answer

//Googled Answer
41 changes: 29 additions & 12 deletions Week-3.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
1. Write a simple React component that simply prints "I am a component" to the screen. Be sure to include all necessary imports, exports, etc...

2. Practice With Loops: In React, we often use the map function to iterate over an array held in state. To get more practice with this, write a vanilla javascript for loop that outputs the same thing as the map function below.
// 1. Write a simple React component that simply prints "I am a component" to the screen. Be sure to include all necessary imports, exports, etc...
import React, {component} from 'react';

class Simple extends Component {
render() {
return (
<div>
"I am a component"
</div>
);
}
}
export default Simple;


var stuffArray = [42, "Arthur Dent", 1978, "Zaphod", "Vogon", "Marvin, the Paranoid Android"]
// 2. Practice With Loops: In React, we often use the map function to iterate over an array held in state. To get more practice with this, write a vanilla javascript for loop that outputs the same thing as the map function below.

stuffArray.map(function(el, i){
console.log(el + " is at index: " + i)
})

// your for loop here, you can use the same stuffArray array
var stuffArray = [42, "Arthur Dent", 1978, "Zaphod", "Vogon", "Marvin, the Paranoid Android"]

// stuffArray.map(function(el, i){
// console.log(el + " is at index: " + i)
// })

3. Basic sorting: Find the cheapest price -- you are given a list of prices and need to find the signle lowest price from the array. Write a function that takes in an array of numbers, and returns the lowest price
// for(let i=0;i<stuffArray.length;i++){
// console.log(`${stuffArray[i]} is at index: ${i}`);
// }

var steal = function(){
//
// 3. Basic sorting: Find the cheapest price -- you are given a list of prices and need to find the single lowest price from the array. Write a function that takes in an array of numbers, and returns the lowest price
var prices = [22.95,19.95,63.99,63.95,12.78]

// your logic here

var steal = function(arr){
tempArr = arr.sort()
return tempArr[0]
}

console.log(steal(prices))
Empty file added {
Empty file.