get help in general - we have more specialized help rooms here: https://gitter.im/FreeCodeCamp/home
yow fam on my repl.it i am returning the right objects but when i paste everything on fcc theres a incorrect return value. heres my code:
// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold",
}
};
var collectionCopy = JSON.parse(JSON.stringify(collection));
function updateRecords(id, prop, value) {
if(prop !== 'tracks' && value !== '') {
collection[id][prop] = value;
}
else if(prop === 'tracks' && !collection[id].hasOwnProperty('tracks') ) {
collection.tracks = [value];
}
else if(prop === 'tracks' && value !== '') {
collection[id].tracks.push(value);
}
else if(value === '') {
delete collection[id][prop];
}
return collection;
}
updateRecords(5439, "tracks", "Take a Chance on Me");//tracks should have "Take a Chance on Me" as the last element.
this is the culprit. but i think its a bug.
updateRecords(5439, "tracks", "Take a Chance on Me");//tracks should have "Take a Chance on Me" as the last element.
collection.tracks = [value];
function booWho(bool) {
// What is the new fad diet for ghost developers? The Boolean.
if(bool === true || bool === false){
return true;
}else{
return false;
}
}
booWho(null);
function booWho(bool) {
// What is the new fad diet for ghost developers? The Boolean.
if(bool == true || bool == false){
return true;
}else{
return false;
}
}
booWho(null);
loose
equivalent
aisolae sends brownie points to @lydatech :sparkles: :thumbsup: :sparkles:
:star2: 2404 | @lydatech |http://www.freecodecamp.com/lydatech
@tiagocorreiaalmeida
let number = 50
let answer = number/(1-0.18)
let remaining = number - answer
would this work?
let number = 50
let answer = number/(1-0.18)
let remaining = number - answer
number
50
answer
60.975609756097555
remaining
-10.975609756097555
answer = number/(1+0.18)
42.37288135593221
remaining = number-answer
7.627118644067792
this is closer
1-0.18
instead of just .82
?
var userInput = "rock";
var randomNumber="";
userInput = userInput.toLowerCase();
function getcomputerChoice(){
randomNumber = Math.floor(Math.random() * 2 );
if (randomNumber == 0 ){
return "rock";
}
else if (randomNumber == 1){
return "paper";
}
else {
return "sciccors";
}
}
function determineWinner(userChoice, computerChoice){
if (userChoice === computerChoice){
return "Game was a tie";
}
if (userChoice === "rock") {
if (computerChoice === "paper")
{return "Computer Wins"; }
}
else {
return "user win";
}
if (userChoice === "rock") {
if (computerChoice === "scissors"){
return "user Win";
}
}
else {
return "computer win";
}
if (userChoice === "paper"){
if (computerChoice === "scissors"){
return "Computer Win";
}
}
else {
return "user win";
}
function playGame(){
var userChoice = userInput;
var computerChoice = getcomputerChoice();
console.log('You threw: ' + userChoice);
console.log('The computer threw: ' + computerChoice);
}
playGame();
if (userChoice === "rock") {
aisolae sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 449 | @korzo |http://www.freecodecamp.com/korzo
programnovice sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1832 | @dhcodes |http://www.freecodecamp.com/dhcodes
darrenfj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6506 | @manish-giri |http://www.freecodecamp.com/manish-giri
programnovice sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2007 | @darrenfj |http://www.freecodecamp.com/darrenfj
can someone help me with the cash in the drawer problem, i am trying to sum all cash in drawer using reduce method, what's the problem with this method?
var totalcid = cid.reduce(function(a,b) {
return a[1]+b[1];
}, 0);
this is the cash in the drawer array
[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]
return a + b[1];
gogminsam sends brownie points to @rmdawson71 :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @rmdawson71 |http://www.freecodecamp.com/rmdawson71
engjell00 sends brownie points to @coymeetsworld and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8443 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2998 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
bundle.js:760 POST http://monkmessages-env.us-east-2.elasticbeanstalk.com/message?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjU5YWVlOGRjNDNmNzc5MDQ5ZmRiZjY4OCIsImZpcnN0TmFtZSI6InQiLCJsYXN0TmFtZSI6InQiLCJlbWFpbCI6InRAdC5jb20iLCJwYXNzd29yZCI6IiQyYSQxMCQwRHBCR2xHZDV2UXhTREN3d2REMnUuL3paNUN6aWVZL2NNenY1bmEvTDlmdkxjd1IwTFpSNiIsIl9fdiI6MCwibWVzc2FnZXMiOltdfSwiaWF0IjoxNTA0NjM1MTI2LCJleHAiOjE1MDQ2NDIzMjZ9.iR8U7dBPH_HzkOj8w5dqit9oKXwr5MxGiZo9oQpvWIM 502 (Bad Gateway)
bundle.js:676 SyntaxError: Unexpected token < in JSON at position 0
.
is used for classes and #
is used for ids
2017/09/05 14:47:40 [error] 4308#0: *40 upstream prematurely closed connection while reading response header from upstream, client: 172.31.8.248, server: , request: "POST /message?token=
and so on
rdnelson2010 sends brownie points to @mstellaluna :sparkles: :thumbsup: :sparkles:
:cookie: 768 | @mstellaluna |http://www.freecodecamp.com/mstellaluna
// -----------------------ON KEYPRESS-------------------------
$("#searchTerm").keypress(function(e) {
// Keypress.
if (e.keyCode === 13) {
// When spacebar is pressed.
$("#output").empty();
var searchTerm = $("#searchTerm").val();
// Iterate through streamers and get the API of each one of them.
$.ajax({
type: "GET",
url: "https://api.twitch.tv/kraken/streams/" + searchTerm, // Each streamer's user name gets added to URL.
headers: {
"client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
},
success: function(twitch) {
// This contains each streamer's API.
if (twitch.stream !== null) {
// If streamers are online...
var logo = twitch.stream.channel.logo;
var name = twitch.stream.channel.display_name;
var status = twitch.stream.channel.status;
var game = twitch.stream.channel.game;
var url = twitch.stream.channel.url;
$("#output").append(
// Append to #output div.
"<a target = '_blank' href=" +
url +
"><div class = 'well'>" +
"<img id = 'img' src =" +
logo +
">" +
"<br></br>" +
"<p id = 'name'>" +
name +
"</p>" +
"<hr></hr>" +
"<p id = 'status'>" +
status +
"</p>" +
"<hr></hr>" +
"<p id = 'online'>Online</p>" +
"</div></a>"
); // End of online append.
} else if (twitch.stream === null) {
$.ajax({
// If streamers are offline...
type: "GET",
url:
"https://api.twitch.tv/kraken/channels/" + searchTerm + "?callback?", // Get info from their channel instead of stream.
headers: {
"client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
},
success: function(twitchOffline) {
console.log(twitchOffline.status);
// API of streamer's channel.
var logo = twitchOffline.logo != null // If logo exists,
? (logo = twitchOffline.logo) // logo conserves properties.
: (logo =
"https://pre06.deviantart.net/1a10/th/pre/f/2015/291/5/1/logo_twitch_iosversion_by_akiruuu-d9djk9s.png"); // If not, logo is now this image.
var url = twitchOffline.url;
var status = twitchOffline.status != null // If status exists,
? (status = twitchOffline.status) // status conserves properties.
: (status = "404 not found"); // If not, status displays "404 not found".
var displayName = twitchOffline.display_name;
$("#output").append(
// Append to the same #output div.
"<a target = '_blank' href =" +
url +
"><div class = 'well well-md'>" +
"<img id = 'img' src =" +
logo +
"><br></br>" +
"<p id = 'name'>" +
displayName +
"</p>" +
"<hr></hr>" +
"<p id = 'status'>" +
status +
"</p>" +
"<hr></hr>" +
"<p id = 'offline'>Offline</p>" +
"</div></a>"
); // End of offline append.
} // End of nested success function.
}); // End of nested ajax call.
} // End of else statement.
} // End of success function.
}); // End of ajax call.
} // End of if statement.
}); // End of searchTerm function.
"https://api.twitch.tv/kraken/channels/" + searchTerm + "?callback?", // Get info from their channel instead of stream.
This is where it all happens
error: function (twitch) {
},
burinson sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles: