mrpowers / code_quizzer Goto Github PK
View Code? Open in Web Editor NEWProgramming practice questions with Ruby, JavaScript, Rails, and Bash.
Home Page: http://www.codequizzes.com/
Programming practice questions with Ruby, JavaScript, Rails, and Bash.
Home Page: http://www.codequizzes.com/
Strings can be combined using the plus (+) sign. This is called string concatenation.
Can someone please help me add specs to this site!?
Shouldn't you introduce comparison operators before using them here? I can logic out <
and >
, but the ===
would have been new to me.
I think this needs to be weaved in a little better. As the reader, at the time operators/operands are introduced, I don't feel I have enough info to understand them completely. For example:
"In the following statement, 4 and 5 are referred to as operands and + is the operator."
^I understand operators and operands in this instance, but I'm not totally clear on the meanings of operand or operator because I'm not sure — based on this example — how far the concepts apply. For example, are there operands/operators in var x = function(array) { console.log(5 + 7)}? If so, what are they?
Let's chat about the most logical place for operators/operands.
change "lala minus three" to lala - 3
this three chapters http://www.codequizzes.com/javascript-book/infinity-nan
http://www.codequizzes.com/javascript-book/truthy-falsy
http://www.codequizzes.com/javascript-book/and-or-operators
should be before "introduction to objects" because objects are harder than this.
Structure the explanations consistently in lines 32, 38, and 44. For example, in line 32, the explanation is given in JavaScript text (my preferred route); in lines 38 and 44, the explanation is in plain text, removed from the example.
Add a single quotes example below “this is a string” called ‘this is a string, too’
I think you need to introduce console.log before you start using it in the examples. Maybe add an intro chapter before we get into strings, numbers and Booleans? The intro chapter would say (1) JavaScript is the language of the web. (2) Here's how you can use JavaScript in your browser (open the console). We can "print" the results of any operation using the console.log() function. (3) Now it's time to learn how JavaScript works, starting with the types of data found in JavaScript. First up: Strings, Numbers, and Booleans.
It should be like this:
function joinIfString(array){
var result = "";
for(var i =0; i < array.length; i++){
if(typeof(array[i])== "string"){
result += array[i];
}
}
return(result);
}
var planet = ["earth", "fire", 34, undefined, "wind", [], "water"];
var r = joinIfString(planet); // you have (arr) here which is not defined
console.log(r);
For this question
Replace the "l" in the following string with "m":
word = "lace"
we could do word.gsub("l", "m")
instead
word[0] = "m"
puts word
When variables are reassigned, they completely forget about any of their former values. In the above example, when b is reassigned to 3, b forgets that it was once assigned to "hello world".
When I try to edit my account (gear link), it says the page doesn't exist.
The boolean condition 7 === 7 evaluates to true, so the code block associated with the if statement is executed and the y variable is reassigned to the string "house of pain".
It think it's more effective to introduce this point once than to keep making the small corrections.
FANBOYS refers to the coordinating conjunctions "for," "and," "nor," "but,", "or," "yet," and — most pertinent to the book — "so."
Every time you have a complete sentence that follows a FANBOYS word, it must be preceded by a comma. Here are examples:
David is tired today, so he won't be 100%.
The dog looks like he got into the trash again, so we won't need to feed him tonight.
Either you give me my cereal right now, or you'll be sorry come tomorrow.
Move this line to the markdown file. "Perform these exercises" is more like a header for the entire exercises section, so it should exist above/outside the exercises themselves.
It's useful to understand what JavaScript is doing here. In the statement x = x + 2, JavaScript first evaluates the expression on the right (i.e. x + 2
) using the old value of x. The variable on the left, x
, is then reassigned to a new value: (old)x + 2. In this case, the value of (old)x + 2 is 90, so the new value of x = 90.
...tempted to say the variable phone equals the value "addicted"...
(Change to italics to distinguish from the strings)
I would make this the same variable name as the example below (i.e. var catSounds) in order to illustrate the complete thought. We should also say something about using lower case for the first letter of a variable.
The following example shows how to increment the variable x by 2. We do this by reassigning x to the value x + 2:
The blah variable is initially assigned to the "meh" string. The motivation variable is initially assigned to the "super!!!" string.
**The third line of code reassigns the variable blah
to the variable motivation
, which in turn is assigned to its own value ("super!!!"
). Note that blah
forgets its former value, "meh", the moment we reassign. By reassigning blah
to motivation
, we are saying that blah
should now have the same value as motivation
. And what is that value? "super!!!"
To drive this point home, what would happen if we reassigned motivation = "more than super!"
and printed console.log(blah)?**
The ++ operator is used frequently, especially in loops (which we'll cover in the upcoming sections).
...does not need to be re-declared; that is, you do not need to repeat the var symbol.
Following the logic from line 35, I think this should be:
happy = ":–)";
The catSounds variable is now assigned to the value "meow". We can confirm this with console.log:
The string "blah" is not equal to the string "hi", so the boolean condition "blah" === "hi" evaluates to false. The code in the if code block is not executed.
Should we mention that values can have multiple variables assigned to them (but that variables can only be assigned to one value)? For example, if var x = 4
and var y = 4
, then x + y = 8
. On the other hand, if you assign var test = 10
followed by var test = 20
, then test + test = 40.
JavaScript provides another shortcut, the ++ operator, for incrementing a variable by 1. Common statements such as x = x + 1 are equivalent to x++. Here's an example:
If the boolean condition evaluates to true, then the code block associated with the if statement will be executed. If the boolean condition evaluates to false, then the code block associated with the else statement will be executed instead.
In the following example, the boolean condition is true, so the code block associated with the if keyword is executed.
if ("a" === "a") {
console.log("one direction <3");
} else {
console.log("lfo");
}
The string "one direction <3" will be printed to the console. The code associated with the else keyword (console.log("lfo")
) is not executed.
section http://www.codequizzes.com/javascript-book/truthy-falsy you should specify that there is only 6 types of falsey, "undefined, NaN, null, 0, " ", and false" and the rest are thruty.
The chapter seems to go in reverse-order, with the most general concept coming last. I would recast this chapter as:
The JavaScript programming language includes seven different types of values. We have already introduced three of them: strings, numbers, and booleans.
Types are important because they help determine the kinds of operations you can perform as well as how those operations work. For example, see what happens in your console when you type the command "cat" + 5
. Now try "cat * 5"
. See the difference? As you'll learn, JavaScript does some strange things when you try to combine different types (referred to as "type conversion"), and it's a common complaint with the language — more on that later.
To check the type of a value in JavaScript, we use the operator typeof()
. (Operator is just a fancy programming word that means [what does operator mean?].) The typeof() operator can be used to demonstrate that true
and false
are boolean values:
typeof(true); // "boolean"
typeof(false); // "boolean"
We can also use typeof() to demonstrate that "dmx" is of the type string, and that integers like 8 and floats 6.72 are of the type number:
typeof("dmx"); // "string"
typeof(8); // "number"
typeof(9.99); // "number"
In the expressions above, typeof() is the operator while "dmx", 8, and 9.99 are referred to as "operands."
...the variable b
to the value 3
.
The string "fork" is different than the string "plate", so the boolean condition returns false.
This would be an interesting challenge. It can be solved iteratively or recursively.
Your call on whether or not to capitalize the word Boolean. I'll leave you with data:
https://books.google.com/ngrams/graph?content=Boolean%2Cboolean%2CBOOLEAN&year_start=1800&year_end=2008&corpus=5&smoothing=3&share=&direct_url=t1%3B%2CBoolean%3B%2Cc0%3B.t1%3B%2Cboolean%3B%2Cc0%3B.t1%3B%2CBOOLEAN%3B%2Cc0
http://english.stackexchange.com/questions/4481/should-the-word-boolean-be-capitalized
I want to make CodeQuizzes beautiful - help me!
**Computers are literal and precise. To a computer, for example, "two times the sum of four and three" is not the same as "two times four plus three" :
console.log(2 * (4 + 3)) // 14
console.log(2 * 4 + 3) // 11).
Because computers are extremely strict in the way they interpret commands, it's important that we use precise language when talking about programming.**
Strings can be combined using the plus (+) sign. This is called string concatenation.
You can assign a variable to any type of value. Numbers (e.g. 46), strings ("something"), and Booleans (true
) are all valid examples. (As we will soon see, variables can also be assigned to arrays, functions, and objects.)
The boolean condition evaluates to false, so the lovePoints variable is reassigned to lovePoints minus 60 (40). The number "40" is then printed to the console.
in this chapter http://www.codequizzes.com/javascript-book/loops-with-if
The last example you work with % - but is never explained on the book.
The variable number is assigned to the value 5. The boolean condition (number > 10) evaluates to false, so the code block associated with the if statement is not executed and the number variable is not reassigned. The number variable is still assigned to 5 when it is printed to the console.
In the following statement, 4 and 5 are referred to as operands and + is the operator.
(^I understand in this instance, but I'm not totally clear on what operand or operator mean because I'm not sure how far they apply. For example, are there operands/operators in var x = function(array) { console.log(5 + 7)}
? If so, what are they?
Hello here the question:
lyric = ["laughter", "it's", "free"]
Get the first element of the lyric Array.
The Answer is lyric[0]
and should include lyric.first
lyric = ["laughter", "it's", "free"]
Get the last element of the lyric Array.
The Answer is lyric[-1]
or lyric[2]
and should include lyric.last
It looks weird to start a sentence with lowercase. Maybe we could try "Conditional statements — commonly known as if statements — are used to execute a code block if a given condition is true. The following code will print..."
There's no expression after the line "What does the following expression print to the console?"
Delete: Shorcut (sic) notation is confusing for beginning programmers and the only reason it is being introduced now is because it is used frequently.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.