get help in general - we have more specialized help rooms here: https://gitter.im/FreeCodeCamp/home
alexandrupintilei sends brownie points to @javalavamt :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @javalavamt |http://www.freecodecamp.org/javalavamt
@alexandrupintilei do you know about jquery? I think if I remember i had to use jquery to get the text from the quote box and then it worked
you don't need to "get" the text from the box, this text (the quote) was already obtained when you did the API call
.value
as far as I remember is used to get value from input
, for other elements you need to do .textContent
property. So doing var text = document.getElementById("text").textContent;
will get you the quote text.
"?text="
from window.open
since you already have that in url
.
var callUrl = "https://fcc-weather-api.glitch.me/api/current?lat=";
callUrl += latit;
callUrl += "&lon=";
callUrl += longit;
$.ajax({
url: callUrl,
dataType: "json",
headers: { "Api-User-Agent": "fCC_CodePen_Gersho" },
type: "GET",
success: function(data) {
this is mine (it works)
function getWeather(lat, lon) {
$.ajax({
'url': 'https://fcc-weather-api.glitch.me/api/current?lat=' + lat + '&lon=' + lon,
'type': 'GET',
'success': function(data) {
console.log('https://fcc-weather-api.glitch.me/api/current?lat=' + lat + '&lon=' + lon);
console.log(data);
}
});
}
amitp88 sends brownie points to @sjames1958gm and @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 592 | @gersho |http://www.freecodecamp.org/gersho
:star2: 8958 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
amitp88 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
a van helsing
how goes the code?
slowly
hey guys, I'm nearly done with the Local Weather App, but I'm having trouble getting the F to C converter to work. I made a simple jquery click event for it, but it's not working and I don't know why. Please help :)
function(F,C) {
where is this anonymous function getting the values of F
and C
?
console.log(F)
into that function I get
#temperature
div also contains the temperature so you're comparing something like 67 F
to F
or C
function (F, C) {
is creating new variables called F
and C
within the scope of that function
(F, C)
from that function, the value of F
becomes 38 ℉
C
https://codepen.io/AmitP88/pen/QQpNKp?editors=1010
ok, I may need to make this into a switch case. When I first load the app (when the temp is F), I can click on it to turn to C, but after that, if I click on C, it won't change back
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test run</title>
<link href="new 1.css" rel="stylesheet" type="test/css"/>
</head>
<body>
<h1>test run </h1>
</body>
</html>
new 1.css
?
let isF = true;
and then have your if statements change accordingly likeif(isF) {
temperature.innerHTML = C;
isF = false;
} else {
temperature.innerHTML = F;
isF = true;
}
href='"new 1.css"'
maybe?
i would think it would need
href='"new 1.css"'
maybe?
i don't know if that exists but my first reaction upon reading it was "what the...."
@ezioda004 oh yeah, I had it like this:
if(temperature.innerHTML = F) {
temperature.innerHTML = C;
} else if(temperature.innerHTML = C) {
temperature.innerHTML = F;
}
it works, but only when it's F. After the first click and it turns to C, it won't turn back
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test run</title>
<link href="new1.css" rel="stylesheet" type="test/css"/>
</head>
<body>
<h1>test run </h1>
</body>
</html>
href="./new1.css"
var F = Math.floor(data.main.temp * (9/5) + 32) + ' ' + '℉';
var C = Math.floor(((data.main.temp * (9/5) + 32) - 32) * (5/9)) + ' ' + '℃';
if(temperature.innerHTML = F)
you're assigning F
to temperature.innerHTML
, not comparing.
:trollface: troll problems? notify admins here
@ezioda004 I originally tried this:
if(temperature.innerHTML === F) {
temperature.innerHTML = C;
} else if(temperature.innerHTML === C) {
temperature.innerHTML = F;
}
```
but it didn't work, so I had to change it
$("#temperature").on("click",function(){
if (tempX == C){
tempX = F;
}else{tempX = C}
$("#temperature").html(tempX);
});
<link href="new1.css" rel="stylesheet" type="test/css">
I don't think you need the /
at the end of this tag
temperature.innerHTML = F
it returns a truthy value..thats why your if statements executes and else if never does
Do Not Use Any Spaces
Just like with special characters, spaces can cause problems on your web server. It's a good idea to avoid them in your file names. I even make it a point to name files like PDFs using these same conventions, just in case I ever need to add them to a website. If you feel you need a space to make the file name easier to read, opt for hyphens or underscores instead.
For examples, instead of using "this is the file.pdf" I would use "this-is-the-file.pdf".
https://www.thoughtco.com/naming-css-style-sheet-files-3466881
test/css
is a valid type, either. can you try text/css
?
The value of the attribute should be a MIME type such as text/html, text/css, and so on. The common use of this attribute is to define the type of style sheet linked and the most common current value is text/css, which indicates a Cascading Style Sheet format.
lol i've never seen a kebab that looks like a sandwich
is that banned in america too or what ? xD
% 10
to get last digit then / 10
to shift and did that until i had checked every number
// cn is card number
long long cn = n;
int temp;
// Will store the number of digits in the card number
int cnlength = 0;
int total = 0;
while ( cn > 0 )
{
// Itterate every digit starting from the right
temp = cn % 10;
cn /= 10;
cnlength++;
// do stuff with temp
}
for (i = str.length; i >= 0; i--){
//do stuff
}
function validCard(card) {
card = card.replace(/ /g,""); let n = "";
for (let i = card.length-2; i >= 0; i-=2) {
n+=(card[i]*2)>9 ? (card[i]*2)-9 : card[i]*2 ;
}
return n.split``.reduce((a,b)=>a + +b,0)//%10===0;
}
let n = 0
?
Take the sum of all the digits.
Take the sum of all the digits.
or do they mean the whole digits in card? @Gersho
well, let's see an exemple, should be easier:
123456789 as the card number
we would do
8x2 + 6x2 + 4x2 + 2x2
(1+6 =>7) + (1 + 2 => 3) + 8 + 4 => 22
9 + 7 + 5 + 3 + 1 => 25
22 + 25 => 47
47 % 10 => if 0, card is valid
that's how i understand it anyway
function validCard(card) {
card = card.replace(/ /g,"").split``;
for (let i = card.length-2; i >= 0; i-=2) {
card[i] = (card[i]*2)>9 ? (card[i]*2)-9 : card[i]*2 ;
}
return card.reduce((a,b)=>a + +b, 0) % 10 === 0;
}
+
in the reduce