It works now!
For anyone who's curious, I changed this:
$("#reduceWork").on("click", function() {
var workLength = $("#workLength").text();
$("#workLength").text(workLength - 1);
});
to this:
$("#reduceWork").on("click", function() {
workSeconds = workSeconds - 1;
workTimerSeconds = workSeconds;
countDown = workTimerSeconds;
var workLength = $("#workLength").text();
$("#workLength").text(workTimerSeconds);
});
WTF it was literally just working perfectly and now it's glitching out and showing a bunch of 1s and NaN... I didn't touch anything!!
SO BIZARRE:
if you click the minus button for work length first, and then the plus sign, both work perfectly fine.
if you click the plus button for work length first, it adds 1s to the end, and then when you click the minus sign it goes to NaN
???
@purnakanneganti
var Bike = function() {
// Only change code below this line.
var gear = 1;
this.setGear = function(change){
gear += change;
};
this.getGear = function() {
return gear;
};
};
did anyone got this challenge
var workSeconds = parseInt($("#workLength").text());
mynameissal sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1389 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
isNaN(parseInt("%")) // => true
All errors fixed. Let me know what you guys think:
https://jsfiddle.net/himynameissal/j42p5f4z/4/embedded/result/
Thanks!
function diff(arr1, arr2) {
var newArr = [];
var onlyInArr1 = arr1.filter(function(current1){
return arr2.filter(function(current2){
return current2 === current1
}).length == 0;
});
var onlyInArr2 = arr2.filter(function(current2){
return arr1.filter(function(current1){
return current1 === current2
}).length == 0;
});
newArr = onlyInArr1.concat(onlyInArr2);
return newArr;
}
function diff(arr1, arr2) {
var newArr = [];
var onlyInArr1 = arr1.filter(function(current1){
return arr2.filter(function(current2){
return current2 === current1
}).length == 0;
});
var onlyInArr2 = arr2.filter(function(current2){
return arr1.filter(function(current1){
return current1 === current2
}).length == 0;
});
newArr = onlyInArr1.concat(onlyInArr2);
return newArr;
}
var generateQuote = function() {
return $("h2").text(quoteArr[index]["quote"]).css(style);
};
mbrad26 sends brownie points to @motass :sparkles: :thumbsup: :sparkles:
:star: 314 | @motass | http://www.freecodecamp.com/motass
dhcodes sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 451 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
dhcodes sends brownie points to @motass :sparkles: :thumbsup: :sparkles:
:star: 315 | @motass | http://www.freecodecamp.com/motass
sidkrip sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 329 | @dhcodes | http://www.freecodecamp.com/dhcodes
code21k sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 331 | @dhcodes | http://www.freecodecamp.com/dhcodes
.quote:hover {
background: #996633;
border: 2px solid #996633;
color: black;
}
.quote {
background: rgba(0, 0, 0, 0.3);
border: 2px solid #996633;
color: #fff;
float: left;
font-weight: bold;
}
mbrad26 sends brownie points to @dukbcaaj :sparkles: :thumbsup: :sparkles:
:star: 390 | @dukbcaaj | http://www.freecodecamp.com/dukbcaaj
.css()
function countDown(sec, e){
e.innerHTML = sec;
if(sec < 1){
clearTimeout(timerS);
e.innerHTML="DONE!";
}
sec--;
var timerS = setTimeout('countDown('+sec+',"'+e+'")',1000);
}
function getQuote() {
$.get("http://www.stands4.com/services/v2/quotes.php?uid=4835&tokenid=removeme&searchtype=RANDOM", function(data) {
theQuote = data.getElementsByTagName("quote")[0].innerHTML; // .innerHTML fixes some odd bug where theQuote can only be used once
theAuthor = data.getElementsByTagName("author")[0].innerHTML ;
$('#quote').html('"' + theQuote + '"');
$('#quoteBy').html("-" + theAuthor);
$('#twtBtn').attr("data-text", "hello"); //insert text into tweet - NOT WORKING
});
}
I can't seem to get .attr() to add to my #twtBtn HTML, at least within .get()'s callback. It works fine outside of the callback, but I need it within the callback to access my 'theQuote' variable later (which I can't use outside of .get()). Can anyone shed some light?
function countDown(sec, e){
e.innerHTML = sec;
if(sec < 1){
clearTimeout(timerS);
e.innerHTML="DONE!";
}
sec--;
var timerS = setTimeout(countDown(sec,e),1000);
}
stacyhere sends brownie points to @jnmorse :sparkles: :thumbsup: :sparkles:
:star: 383 | @jnmorse | http://www.freecodecamp.com/jnmorse
stacyhere sends brownie points to @jondcoleman :sparkles: :thumbsup: :sparkles:
:star: 528 | @jondcoleman | http://www.freecodecamp.com/jondcoleman
document.getElementById("start").addEventListener('click', function(e){
console.log(e.target)
})
Does anyone know why this .attr doesn't work, when .html does?
function getQuote() {
$.get("http://www.stands4.com/services/v2/quotes.php?uid=4835&tokenid=removeme&searchtype=RANDOM", function(data) {
theQuote = data.getElementsByTagName("quote")[0].innerHTML; // .innerHTML fixes some odd bug where theQuote can only be used once
theAuthor = data.getElementsByTagName("author")[0].innerHTML ;
$('#quote').html('"' + theQuote + '"');
$('#quoteBy').html("-" + theAuthor);
$('#twtBtn').attr("data-text", "hello"); //insert text into tweet - NOT WORKING
});
}
Here's my codepen: http://codepen.io/mholst1/pen/zrymgw?editors=1111
sreeves89 sends brownie points to @jondcoleman :sparkles: :thumbsup: :sparkles:
:star: 530 | @jondcoleman | http://www.freecodecamp.com/jondcoleman
$(document).ready(function(){
var session=25;
var breakLength=0;
$('.adjust').click(function(){
var id = $(this).attr('id');
console.log("ID: "+id);
});
});
my code is not printing the id
mholst1 sends brownie points to @jondcoleman :sparkles: :thumbsup: :sparkles:
:star: 532 | @jondcoleman | http://www.freecodecamp.com/jondcoleman
var count = "";
var calc= [];
var operation = "";
var number = "";
var math = {
"+": function (x,y) {x+y},
"-": function (x,y) {x-y},
"/": function (x,y) {x/y},
"*": function (x,y) {x*y},
"%": function (x,y) {x%y}
}
var answer = 0;
$("button").click(function() {
var text = $(this).attr("value");
if (text !== "AC" && text !== "=" && text !== "CE" && text !== "ANS") {
if (text === "+" || text === "-" || text === "*" || text === "/" || text === "%" ) {
number = parseInt(count);
calc.push(number);
operation = text;
count = count + text;
$(".textbox").val(count);
}
else {
number = number + text;
count = count + text;
$(".textbox").val(count);
}
}
else if(text === "AC") {
count = "";
calc = "";
$(".textbox").val(count);
}
else if(text === "=") {
calc = "";
answer = math[operation](calc[0], calc[1]);
$("textbox").val(math[operation](calc[0], calc[1]));
}
});
ahmo10 sends brownie points to @lennixm :sparkles: :thumbsup: :sparkles:
:star: 267 | @lennixm | http://www.freecodecamp.com/lennixm
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Kacper Porembski</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="#Home">Home</a></li>
<li><a href="#About">About</a></li>
<li><a href="#Portfolio">Portfolio</a></li>
<li><a href="#Contact">Contact</a></li>
</ul>
</div>
</div>
</nav>
:bulb: to format code use backticks! ``` more info
"<button class='button' value='3'>
3
</button>"
emillion90 sends brownie points to @jondcoleman :sparkles: :thumbsup: :sparkles:
:star: 534 | @jondcoleman | http://www.freecodecamp.com/jondcoleman
$(".incwrk").click(function(){
$("#min").html(function(){
var added = ("#min").html() + 10
return added;
});
});
5
to?
("#min")
, need the $
infrontvar added = ("#min").html() + 10
$("#min").append("5");
min
.
blayman sends brownie points to @kme211 :sparkles: :thumbsup: :sparkles:
:star: 323 | @kme211 | http://www.freecodecamp.com/kme211
blayman sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star: 632 | @manish-giri | http://www.freecodecamp.com/manish-giri
joeymelnick sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star: 633 | @manish-giri | http://www.freecodecamp.com/manish-giri
I am creating separate classes for each section of my webpage, using a different background image in each one. My CSS is of the format:
.intro-section {
background: url("url text here") no-repeat center center fixed;
}
for whatever reason, it is having trouble finding the url I have given. What's interesting is if I use the same exact url in an <img> element in my HTML box, it has no trouble finding the image. Can somebody please explain what the issue might be?
[{quote: "A quote", likes: 0}, {quote: "Another quote", likes: 0}]
// after quotes have been defined
quotes = quotes.map(function(quote) {
// return an object for each quote in the array
// with the quote being the value of "text"
// and likes being 0 being the default value of "likes"
return {
text: quote,
likes: 0
};
})
jxvo92 sends brownie points to @kme211 :sparkles: :thumbsup: :sparkles:
:star: 324 | @kme211 | http://www.freecodecamp.com/kme211
valmunos sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1116 | @mutantspore | http://www.freecodecamp.com/mutantspore
I want to apply something like :
#display {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
}
But it doesn't seem to work
unlimiworks sends brownie points to @kme211 :sparkles: :thumbsup: :sparkles:
:star: 325 | @kme211 | http://www.freecodecamp.com/kme211
cursor: pointer;
to the CSS for it.
hi guys, i don't really have a specific question i guess. I'm working on the local weather project and it's my first time working with api calls so i've been doing research. i have been actively trying to keep my project code for the work so far as pure javascript, so that i can understand the language underlying language before using libraries or frameworks.
anyways, i guess my question is are there any examples of i guess 'pretty' js implementations of api calls. i'm using the api @ openweathermap if curious