get help in general - we have more specialized help rooms here: https://gitter.im/FreeCodeCamp/home
the1987 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
thekholm80 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
daddycardona sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
thekholm80 sends brownie points to @daddycardona :sparkles: :thumbsup: :sparkles:
filter()
when i did it
filter()
and inside the filter callback i used Object.keys()
and every()
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var sourceKeys = Object.keys(source);
var sourceVals = Object.values(source);
for (var i = 0; i < collection.length; i++) {
for (var j = 0; j < sourceKeys.length; j++) {
if (collection[i].hasOwnProperty(sourceKeys[j])) {
if (collection[i][sourceKeys[j]] === sourceVals[j]) {
arr.push(collection[i]);
console.log(collection[i][sourceKeys[j]]);
}
}
}
}
console.dir(arr);
// Only change code above this line
return 'arr';
}
return 'arr';
?
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
for this one when you first check the a property ` in this one the 2nd element will get pushed into arr, because both have a property with a and the value to 1
check the second property as well
and that is why I decided to try the filter() method and every() but because I simply am not understanding them well enough or how to check it I am stuck I just want to cuss at javascript lol
hello, I have this code is there a way i can nest filter and map methods
` ``
var filter = watchList.filter((value) => {
return value.imdbRating.valueOf() >= 8.0;
})
var filteredList = filter.map((value) => {
return {Title:value["Title"], imdbRating:value["imdbRating"]};
});
```
watchList.filter().map()
item.hasOwnProperty(key) && item[key] === source[key];
so this is the condition that you want to test for each keyvar valid = true
for each key
if no key or value doesnt match - valid = false
endfor
if (valid) push
ankorgh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
let minQtr = d3.min(gdpData.data, function(d) { return d[0]; });
goes to let minQtr = d3.min(gdpData.data, d => d[0]);
var bar = chart.selectAll("g")
.data(gdpData.data)
.enter().append("rect")
.attr("title", "GDP")
- .attr("x", function(d) { return x(d[0]); })
- .attr("y", function(d) { return y(d[1]); })
- .attr("height", function(d) { return chartHeight - y(d[1]); })
+ .attr("x", (d) => x(d[0]))
+ .attr("y", (d) => y(d[1]))
+ .attr("height", (d) => CHART_HEIGHT - y(d[1]))
.attr("width", barWidth - 1)
.on("mouseout", function() {
hideTooltip();
i was just looking at
node.style('left', (d) => { return d.x + 'px'; })
.style('top', (d) => { return d.y + 'px'; })
.call(force.drag);
link.attr('x1', (d) => { return d.source.x })
.attr('y1', (d) => { return d.source.y })
.attr('x2', (d) => { return d.target.x })
.attr('y2', (d) => { return d.target.y });
would look a lot cleaner with implicit return
daddycardona sends brownie points to @sjames1958gm and @thekholm80 and @coymeetsworld :sparkles: :thumbsup: :sparkles:
I am getting a strange quirk.postion: absolute
hides the element even after i added z-index: 99
.
the above mentioned statement is on line-138 in the given codepen below.
https://codepen.io/neel111/pen/EvMmgZ
by removing the position: absolute
the element show up. Why position: absolute
is hidding the element?
var something = collection.filter(function(e, i) {
Object.keys(source).every(function(key, item) {
item
is
item
be the index of the current element?
every()
every(element, index, array)
Callback parameter Definition
value The value of the array element.
index The numeric index of the array element.
array1 The array object that contains the element.
function whatIsInAName (collection, source) {
var arr = [];
// ...
return arr;
}
function whatIsInAName (collection, source) {
var arr = [];
arr = collection.filter(function(item) {
// ...
});
return arr;
}
item
source
filter()
you have to return them, sofunction whatIsInAName (collection, source) {
var arr = [];
arr = collection.filter(function(item) {
return // ...
});
return arr;
}
Object.keys(source)
comes in
Object.keys(source)
will create an array of the keys in source
every()
will let you look at each element in that array and check it against item
every()
you need to return them
yes
yeah okay so your return for filter should be Object.keys(source).every(fn//)
function whatIsInAName (collection, source) {
var arr = [];
arr = collection.filter(function(item) {
return Object.keys(source).every(fn//)
});
return arr;
}
every()
and you should be there
every()
should just check the 2 values and return whether they're a match or not
Object.keys()
is going to create an array of keys from source
so every()
is going to look at each key. To compare the values you need to use the []
notation on the objects since you're going to be using a variable
var source = {a: 1, b: 2};
var arr = Object.keys(source);
console.log(arr) // => [a, b]
arr.every(function(key) {
console.log(source[key]) // => 1 2
});
thekholm80 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
daddycardona sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
function array() { ... }
callback
Function is a predicate, to test each element of the array. Return true to keep the element, false otherwise, taking three arguments:
exactly what I have been missing this whole time was right in my face lol
knight2 sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
oh yah look it must still be down:
api offline
darrenfj sends brownie points to @daddycardona :sparkles: :thumbsup: :sparkles:
just1witness sends brownie points to @darrenfj and @daddycardona :sparkles: :thumbsup: :sparkles:
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, Monospace;
}
p {
font-size: 16px;
font-family: Monospace;
}
.class1smaller-image {
width: 100px;
}
.class2thick-green-border{
border-color:green;
border-width:10px;
border-style:solid;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<img class="class1smaller-image" "class2thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">
<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
border: solid green 10px;
?
<img class="class1smaller-image class2thick-green-border">
smaller-image
and thick-green-border
without the class 1 class 2 part
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, Monospace;
}
p {
font-size: 16px;
font-family: Monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">
<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
<p>Here's a <a href="http://freecatphotoapp.com">"catphotos"</a> for you to follow.</p>
Given two strings, find the number of common characters between them.
Example
For s1 = "aabcc" and s2 = "adcaa", the output should be
commonCharacterCount(s1, s2) = 3.
Strings have 3 common characters - 2 "a"s and 1 "c".
function commonCharacterCount(s1, s2) {
s1 = s1.split("");
s2 = s2.split("");
var s1Length = s1.length;
var s2Length = s2.length;
var count = 0;
for(let i = 0; i < s1Length; i++){
for(let j = 0; j < s2Length; j++){
if(s1[i] === s2[j] && s1[i] != null){
console.log(s1[i]+" is equal to "+s2[j]);
s1.splice(i,1);
s2.splice(j,1);
count ++;
}
}
}
console.log(s1,s2);
return count;
}
<div class="row">
<div class="col-xs-6>"><label><input type="radio" name="indoor-outdoor"> Indoor</label></div>
<div class="col-xs-6>"><label><input type="radio" name="indoor-outdoor"> Outdoor</label></div>
</div>
<div class="row">
<div class="col-xs-6>"><input type="radio" name="indoor-outdoor"> Indoor</div>
<div class="col-xs-6>"><input type="radio" name="indoor-outdoor"> Outdoor</div>
</div>
.test { color: maroon; min-width: 80vw;}
to your styles.css and a <div class="test"></div>
to your html.
<blink></blink>
thekholm80 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
function largestOfFour(arr) {
for (var i = 0; i < arr.length; i++) {
var max = Math.max(...arr[i]);
}
return max;
}
largestOfFour([
[4, 5, 1, 3],
[13, 27, 18, 26],
[32, 35, 37, 39],
[1000, 1001, 857, 1]
]);
I'm working on the Return Largest Numbers in Arrays section and so far my code gets the largest number which is 1001. I just need to return the rest of it's sub-array ([1000,857,1]). Is there a way for me to use the value (1001) to get the sub-array that it is in? Can someone point me in the right direction?
function executeQuery($query){
$db_host = "localhost";
$db_user = "people";
$db_pass = "PEWA{D!cC-]i";
$db_name = "expo";
$dbCon = mysqli_connect($db_host,$db_user,$db_pass,$db_name) or die("Database Connection Failed");
//check db connection state
if (empty($dbCon))
echo "Database connection failed";
else {
$result = $dbCon->query($query);
//close db connection
mysqli_close($dbCon);
//if query was successful
if($result)
return $result;
else
return 0;
}
darrenfj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
supra01 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
switch (str.charAt(0)) {
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U':
str += 'way';
break;
switch (str.charAt(0)) {
case 'a':
case 'e':
....
translatePigLatin("glove") should return "oveglay".
why lol
@sjames1958gm
function largestOfFour(arr) {
var largestNum =[];
for (var i = 0; i < arr.length; i++) {
largestNum.push(Math.max.apply(null, arr[i]));
}
return largestNum;
}
largestOfFour([
[4, 5, 1, 3],
[13, 27, 18, 26],
[32, 35, 37, 39],
[1000, 1001, 857, 1]
]);
Thanks again I was able to figure it out!
supra01 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
jenkuy sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
oveglay
it did not say that in the description lol
if( charAt(1) == 'l')
that fixed it
while (change>0 && cid[0][1]>0) {
switch (true) {
case (change >= 100):
if (cid[8][1]>0) {
change -=100;
changearr[0][1] += 100;
cid[8][1] -= 100;
break;
}
case (change >= 20):
if (cid[7][1]>0) {
change -=20;
changearr[1][1] += 20;
cid[7][1] -= 20;
break;
}
case (change >= 10):
if (cid[6][1]>0) {
change -=10;
changearr[2][1] += 10;
cid[6][1] -= 10;
break;
}
case (change >= 5):
if (cid[5][1]>0) {
change -=5;
changearr[3][1] += 5;
cid[5][1] -= 5;
break;
}
case (change >= 1):
if (cid[4][1]>0) {
change -=1;
changearr[4][1] += 1;
cid[4][1] -= 1;
break;
}
case (change >= 0.25):
if (cid[3][1]>0) {
change -=0.25;
changearr[5][1] += 0.25;
cid[3][1] -= 0.25;
break;
}
case (change >= 0.1):
if (cid[2][1]>0) {
change -=0.1;
changearr[6][1] += 0.1;
cid[2][1] -= 0.1;
break;
}
case (change >= 0.05):
if (cid[1][1]>0) {
change -=0.05;
changearr[7][1] += 0.05;
cid[1][1] -= 0.05;
break;
}
case (change >= 0.01):
if (cid[0][1]>0) {
change -=0.01;
changearr[8][1] += 0.01;
cid[0][1] -= 0.01;
break;
}
default:
break;
}
}
gogminsam sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
darrenfj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
i love that @Manish-Giri gets all the testing spam
manish-giri sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
thekholm80 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
thekholm80 sends brownie points to @texas2010 :sparkles: :thumbsup: :sparkles:
darrenfj sends brownie points to @texas2010 :sparkles: :thumbsup: :sparkles:
node-sass
rebuilt because i upgraded node
-g
you could use
on the node install or the node-sass
package?
but I remember there was a
-g
you could use
I wonder how many hipsters cry when they see this?
Note that OS X is just a flavour of Unix
Q: Will you hand-deliver this to London, England. If so, will you agree to a public fist fight?
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str = str.split("");
for (let i = 0; i < str.length; i++){
if(str[i] == str[i].toLowerCase() && str[i+1] == str[i+1].toUpperCase()){
str[i+1] = "-";
}
if(str[i] == str[i].toUpperCase()){
str[i] = str[i].toLowerCase();
}
if(str[i] == " "||str[i] == "_"){
str[i].split(i, 1);
str[i] = "-";
}
}
return str.join("");
}
spinalCase('thisIsSpinalTap');
abohannon sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"scripts": {
"start": "node server.js"
}
The quick brown fox jumps over the lazy dog.
oVer
public class PangramChecker {
public static boolean check(String sentence) {
String MaleLitery = "qwertyuiopasdfghjklzxcvbnm", DuzeLitery = "QWERTYUIOPASDFGHJKLZXCVBNM";
char[] TablicaCharow = new char[sentence.length()];
char[] MaleLitery1 = new char[MaleLitery.length()];
char[] DuzeLitery1 = new char[DuzeLitery.length()];
int[] TablicaIlosciLiter = new int[MaleLitery.length()];
boolean[] TablicaPrawdy = new boolean[MaleLitery.length()];
boolean result = true;
for (int i = 0; i < sentence.length(); i++) {
TablicaCharow[i] = sentence.charAt(i);
}
for (int i = 0; i < MaleLitery.length(); i++) {
MaleLitery1[i] = MaleLitery.charAt(i);
DuzeLitery1[i] = DuzeLitery.charAt(i);
TablicaIlosciLiter[i] = 0;
}
for (int i = 0; i < sentence.length(); i++) {
for (int j = 0; j < MaleLitery.length(); j++) {
if (TablicaCharow[i] == MaleLitery1[j]||TablicaCharow[i] == DuzeLitery1[j]) {
TablicaIlosciLiter[j]++;
}
}
}
for (int i = 0; i < TablicaIlosciLiter.length; i++) {
if (TablicaIlosciLiter[i] >0)
{
TablicaPrawdy[i]=true;
}
else
{
TablicaPrawdy[i]=false;
}
result=result&&TablicaPrawdy[i];
}
return result;
}
}
import java.util.*;
public class PangramChecker {
public boolean check(String sentence){
//code
String replaced = sentence.replaceAll("[^A-Za-z]", "");
Set<String> letters = new HashSet<>(Arrays.asList(replaced.split("")));
return letters.size() >= 26;
}
}
import java.kata.answer;
because I wanted the pop-up on the page
let isPangram=(s)=>!(new Set(s.replace(/[^a-z]/ig, '')).size < 26)
abohannon sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
darrenfj sends brownie points to @thekholm80 and @manish-giri :sparkles: :thumbsup: :sparkles:
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str = str.split("");
for (let i = 0; i < str.length; i++){
if(str[i] == " " && str[i] != "-" && str[i+1] != str[i+1].toLowerCase() || str[i] == "_"){
str.splice(i, 1);
}
if(str[i] == str[i].toUpperCase()){
if(str[i] != str[0] && str[i] != "-"){
str[i] = "-" + str[i];
}
str[i] = str[i].toLowerCase();
}
}
return str.join("");
}
spinalCase('Teletubbies say Eh-oh');
i'm having trouble motivating myself to finish my last projects
gersho sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
darrenfj sends brownie points to @gersho and @thekholm80 and @manish-giri :sparkles: :thumbsup: :sparkles:
@Manish-Giri @thekholm80 I know you're way past this but this was my js solution - any way to make it better?
let isPangram=(s)=>!(new Set(s.replace(/[^a-z]/ig, '')).size < 26)
@cmccormack good solution :clap:
that's also the first thing I thought of
i'm assuming too, but
Specifying a string as a parameter
The replacement string can include the following special replacement patterns:
Pattern Inserts
$$ Inserts a "$".
$& Inserts the matched substring.
$` Inserts the portion of the string that precedes the matched substring.
$' Inserts the portion of the string that follows the matched substring.
$n Where n is a positive integer less than 100, inserts the nth parenthesized submatch string, provided the first argument was a RegExp object. Note that this is 1-indexed.
is the exact same text from the doc