customerData
object
var customerData = {
name:
}
firstName
, the name you need to look up
customerData[firstName]
?
customerData[firstName].visits
to check the number of visits?
customerData.hasOwnProperty(firstName)
and checking the visits with: customerData[firstName].visits
customerData.visits[i]
visits
property is part of the name object
customerData.hasOwnProperty(firstName)
is equal to firstName
customerData[firstName].visits
var customerData = {
'Joe': {
visits: 1
},
'Carol': {
visits: 2
},
'Howard': {
visits: 3,
},
'Carrie': {
visits: 4
}
};
function greetCustomer(firstName) {
var greeting = '';
if (customerData.hasOwnProperty(firstName)==firstName) {
if (customerData.visits>1){
greeting= ("Welcome back," + firstName + "! So glad to see you again!");
}
else if (customerData.visits==1){
greeting= ("Welcome back," + firstName + "! We're glad you liked us the first time!");
}
}
else {
greeting= ("Welcome! Is this your first time?");
}
return greeting;
customerData[firstName].visits
hasOwnProperty
returns true or false
function greetCustomer(firstName) {
var greeting = '';
if (customerData.hasOwnProperty(firstName)) {
if (customerData[firstName].visits>=2){
greeting= ("Welcome back," + firstName + "! So glad to see you again!");
}
else if (customerData[firstName].visits==1){
greeting= ("Welcome back," + firstName + "! We're glad you liked us the first time!");
}
}
else {
greeting= ("Welcome! Is this your first time?");
}
return greeting;
junipberry sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2358 | @skyc0der |http://www.freecodecamp.com/skyc0der
function greetCustomer(firstName) {
let names = Object.keys(customerData);
for (i = 0; i < names.length; i++) {
if (names[i] === firstName) {
if (customerData[names[i]].visits > 1) {
return "Welcome back, " + firstName + "! So glad to see you again!";
} else if (customerData[names[i]].visits == 1) {
return "Welcome back, " + firstName + "! We're glad you liked us the first time!";
}
} else {
return "Welcome! Is this your first time?";
}
}
}
junipberry sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:warning: junipberry already gave skyc0der points
I need help with the Wherefore art thou
function whatIsInAName(collection, source) {
// What's in a name?
var firstRoundArr = [];
var secondRoundArr = [];
// Only change code below this line
//************************************/
// generate a set of keys
var keysSet = Object.keys(source);
//generate a set of values
var valuesSet = Object.values(source);
//test for object in collectionthat has all the key required 1-round-filter
for (var i=0; i<collection.length; i++){
var match = false;
for (var j=0; j<keysSet; j++){
match = collection[i].hasOwnProperty(keysSet[j]);
}
if(match){
firstRoundArr.push(collection[i]);
}
}
//test the passed object if the values matches
//************************************/
// Only change code above this line
return firstRoundArr;
}
whatIsInAName([{ "a": 1, "b": 2 },
{ "a": 1 },
{ "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
I found a bug in line 15 to line 24.
I try to change the value of the boolean "match" by the return value in line 18;
But, I dunno why it didn't work.
Can anyone help me? I have posted it in other group, but nobody replies
I need help with the Wherefore art thou
function whatIsInAName(collection, source) {
// What's in a name?
var firstRoundArr = [];
var secondRoundArr = [];
// Only change code below this line
//************************************/
// generate a set of keys
var keysSet = Object.keys(source);
//generate a set of values
var valuesSet = Object.values(source);
//test for object in collectionthat has all the key required 1-round-filter
for (var i=0; i<collection.length; i++){
var match = false;
for (var j=0; j<keysSet; j++){
match = collection[i].hasOwnProperty(keysSet[j]);
}
if(match){
firstRoundArr.push(collection[i]);
}
}
//test the passed object if the values matches
//************************************/
// Only change code above this line
return firstRoundArr;
}
whatIsInAName([{ "a": 1, "b": 2 },
{ "a": 1 },
{ "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
I found a bug in line 15 to line 24.
I try to change the value of the boolean "match" by the return value in line 18;
But, I dunno why it didn't work.
"100"
?
"100"
?
function test(str){
return str.match(/abc/g);
}
test("abcabcabcabcabcabcabcabc"); // [ 'abc', 'abc', 'abc', 'abc', 'abc', 'abc', 'abc', 'abc' ]
The loop idea is like:
for(var i = 0; i < str.length-3; i+=3) {
answer.push(str[i] + str[i+1] + str[i+2]);
}
the .match() could work nicely if you modify the regex to work for any string
str.match(/.{3}/g)
abc
then add them in an array?
var str = "This is my really longggg string that is around one hundred characters long. I think it's that long."
"abcdcbger"
=> "['abc', 'dcb', 'ger
']"
g
s to the end of long
to make it 100 characters
what level are you in at school?
ccs99817 sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2361 | @skyc0der |http://www.freecodecamp.com/skyc0der
How can I move my text in the first panel up? https://codepen.io/hermes/pen/eEROzo
Shouldn't it default at the top left corner? Why is it hugging the bottom of the screen?
hermeticlock sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @gothamknight |http://www.freecodecamp.com/gothamknight
So then here's my follow up question. Because when I do margin-left or whatever to move text, it's only for my current resolution, is there a way for me to resize the text, so that it's always by a certain spot on the background image?
My main concern is that I don't want the text interacting with the characters on the page. I want it displayed to the left or right of them.
thinsoldier sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @gothamknight |http://www.freecodecamp.com/gothamknight
.test { color: green } .test { color: red }
it's last rule who gonna be applied on green one, and test element gonna have red text
Anyone able to help debug some bootstrap CSS/fluid-container mischief? I have two sections that are using the same grid framework on a page... one behaves fine but the other refuses to stack properly.
row
divs to enclose your col
divs... that could be one problem.
align=center
attributes are probably not valid, even though things are centered... I guess that the "align" attribute is deprecated, so it might work but you cannot count on it to stay working.
<div class="row">
to be the parent of your column divs...
thayyebsalim sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2364 | @skyc0der |http://www.freecodecamp.com/skyc0der
feldbot sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3193 | @khaduch |http://www.freecodecamp.com/khaduch
var count = 0;
function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count = count;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
default:
return "Change Me";
}
if (card >=2 && card <=6) {
return count + " Bet";
} else if (card >=7 && card <=9) {
return count + " Hold";
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
return count + " Hold";
} else {
return "Change Me"; }
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(2); cc(10);
count
and not the value of the cards, because the switch
statement is handling the card values.
feldbot sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave khaduch points
@Feldbot - the instructions say:
The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
So you should be basing the final return on the value of count
. And you should not have any of the "Change Me" code in there - that should be removed by your edits with new code.
feldbot sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave khaduch points
@Feldbot - you should have something to handle incorrect input, but you don't really want it to have a return of "Change Me"... the line should be replaced with something. In this context, it's not really useful to replace it with anything. In a real situation it would depend on the context - some way to notify the user that there was an error in the input... In my solution for this challenge, I didn't have cases for the "7, 8, 9", but I let the default
handle them, and I did nothing there - count = count;
is the same as doing nothing, if you get what I mean? My code for that looked like this:
default:
// do nothing for 7, 8, 9
} // end of the switch statement
So it just fell through for those values. It made the code a little bit shorter.
`
case 7:
case 8:
case 9:
break;
`
feldbot sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave khaduch points
var myVar = "this string";
and you can continue with other text. For the blocks of code, you do as before - three backquotes on separate lines before and after the code block.
$(document).ready(function() {
$("#tako").click(function() {
var combos = [
"R2",
"R",
"'R",
"L",
"L'",
"L2",
"M",
"'M",
"M2",
"'D",
"D2",
"D",
"'U",
"U2",
"U"
];
for(var randomstring = 0; randomstring < 21; randomstring++)
{var com = combos[Math.floor(combos.length * Math.random())];}
console.log(com);
document.getElementById("outputs").value = com;
});
});
var com = [];
for(var randomstring = 0; randomstring < 21; randomstring++) {
com.push(combos[Math.floor(combos.length * Math.random())]);
}
thetruehoohah sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2367 | @skyc0der |http://www.freecodecamp.com/skyc0der
flyfishingbarbara sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2369 | @skyc0der |http://www.freecodecamp.com/skyc0der
nitinnair89 sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:star2: 1103 | @roxroy |http://www.freecodecamp.com/roxroy
margin: auto
on the element
https://codepen.io/cmccormack/pen/gRPYeO
I have an example using a fixed position element
fdemaa sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1121 | @cmccormack |http://www.freecodecamp.com/cmccormack
object-fit: cover;
to .overimage
background-image
of the div, instead of putting the <img>
tag in there
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return checkProp;
} else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");
sabin20 sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 156 | @redmega |http://www.freecodecamp.com/redmega
feldbot sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @korzo |http://www.freecodecamp.com/korzo
feldbot sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave korzo points
var myObj = {
gift: [1,2,3]
};
var prop = 'gift';
myObj.gift[0];
myObj[prop][0];
feldbot sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave korzo points
function getProperty(obj, key) {
(obj[key]= 'value');
return obj[key].value;
}
flyfishingbarbara sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2370 | @skyc0der |http://www.freecodecamp.com/skyc0der
flyfishingbarbara sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @gothamknight |http://www.freecodecamp.com/gothamknight
feldbot sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave korzo points
@media screen and (max-width:767px){
.forum{
margin:10px 100px;
},
.contact>.par{
margin:20px 40px;
}
}
ldocherty1 sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @gothamknight |http://www.freecodecamp.com/gothamknight
display: none;
from the .navbar css rule. then add $('.navbar').css('display', 'none');
directly under you document ready function.
Problem 1 - I have put an animate.css effect on my section two title text and hr element (line). However, the effect on these elements activates when the page loads. When the user goes to my section 2 I want the effect then to take place. Not to sure how to make that happen.
Problem 2 - Due to me wanting to have my navigation bar at the top of every section apart from section one which is known as #part1
I used the following CSS which is having a major effect on my navigation bar. Nothing is straight and lined up on my navigation bar. In terms of my CSS the display
part is having an effect on the elements within the navbar. However, if I remove display: none;
and everything is lined up, my navigation bar will be visible in section one which is not what I want.
.navbar {
display: none;
position: fixed;
top: 0;
width: 100%;
z-index: 10;
height: 4rem;
background-color: #003554;
}
ldocherty1 sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:warning: ldocherty1 already gave gothamknight points
https://codepen.io/liamdocherty1/pen/dzzOGy
I have put an animate.css effect on my section two title text and hr element (line). However, the effect on these elements activates when the page loads. When the user goes to my section 2 I want the effect then to take place. Not to sure how to make that happen.
ldocherty1 sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:warning: ldocherty1 already gave gothamknight points
ldocherty1 sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2371 | @skyc0der |http://www.freecodecamp.com/skyc0der
display: none;
using a different selection, but nothing changed.