<div class="container">
<div class="row"></div>
</div>
Ctrl + Shift + J
for windows Cmd + Opt + J
for mac to go your browser's console.
just1witness sends brownie points to @jtan3 :sparkles: :thumbsup: :sparkles:
:cookie: 459 | @jtan3 |http://www.freecodecamp.com/jtan3
just1witness sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 418 | @gothamknight |http://www.freecodecamp.com/gothamknight
props
in function component and class component? Is it because function component only works with props?
Hi all, i have a question about scopes in functions..I can't understand it.
For example in book Eloquent Javascript I'm doing the task:
Need make sum function with range - sum(range(1,10))
Creating range function:
function range(a,b) {
var arr = [];
for (var i = a; i<=b; i++) {
arr.push(i);
}
return arr;
}
Checking sum function on existence arr
- and geting undefined
in result
function sum(arr) {
console.log(arr);
//undefined
}
BUT!
if we make loop - we getting our `arr
function sum(arr) {
for (var i =0; i < arr.length; i++) {
console.log(arr[i]);
//arr.elements
}
}
I dont understand this logic.
1)Why we can't see our array without loop in this example?
2) How to transfer data from one function to another function?
I stacked on closures near one year, and dont know how to understand it.
Thanks a lot.
undefined
because you have no return
statement on the function code. Logs you can see on the browser developer tools console.
return
its ok
marat89bluolyu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4471 | @masd925 |http://www.freecodecamp.com/masd925
amitp88 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4472 | @masd925 |http://www.freecodecamp.com/masd925
amare16 sends brownie points to @1532j0004kg and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 258 | @1532j0004kg |http://www.freecodecamp.com/1532j0004kg
:star2: 4475 | @masd925 |http://www.freecodecamp.com/masd925
can anyone tell me what I am doing wrong here 'function whatIsInAName(collection, source) {
// What's in a name?
// Only change code below this line
var arr = [];
for (var i=0;i<collection.length;i++)
{
if(Object.keys(collection[i]) == Object.keys(source))
{
arr.push(collection[i]);
}
}
// Only change code above this line
return arr;
}
whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 });'
function whatIsInAName(collection, source) {
// What's in a name?
// Only change code below this line
var arr = [];
for (var i=0;i<collection.length;i++)
{
for (var j=0;j<source.length;j++)
{
if(Object.keys(collection[i]) == Object.keys(source[j]))
{
arr.push(collection[i]);
}
}
}
// Only change code above this line
return arr;
}
whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 });
.length
property.
source
is an object, not an array.
raza403 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4476 | @masd925 |http://www.freecodecamp.com/masd925
just1witness sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 447 | @korzo |http://www.freecodecamp.com/korzo
function dropElements(arr, func) {
// Drop them elements.
return arr;
}
dropElements([1, 2, 3], function(n) {return n < 3; }); // this changes
dropElements
function so you pass the right type of data in. To invoke the function, you can just do something like func(arr[1])
inside dropElements
or use a loop or whatever you're trying to do
brianwilliams28 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1183 | @cmccormack |http://www.freecodecamp.com/cmccormack
janelledement sends brownie points to @kowalatam :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @kowalatam |http://www.freecodecamp.com/kowalatam
$(".offline").toggle()
erichasegawa sends brownie points to @itsacoyote :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @itsacoyote |http://www.freecodecamp.com/itsacoyote
erichasegawa sends brownie points to @itsacoyote :sparkles: :thumbsup: :sparkles:
:warning: erichasegawa already gave itsacoyote points
ldocherty1 sends brownie points to @itsacoyote :sparkles: :thumbsup: :sparkles:
:cookie: 408 | @itsacoyote |http://www.freecodecamp.com/itsacoyote
janelledement sends brownie points to @kowalatam and @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @kowalatam |http://www.freecodecamp.com/kowalatam
teiwik sends brownie points to @kowalatam :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @kowalatam |http://www.freecodecamp.com/kowalatam