var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', "https://www.erepublik.com/en/military/campaigns-new");
ourRequest.onload = function() {
var x = Object.values(JSON.parse(ourRequest.responseText).battles);
var c = Object.values(JSON.parse(ourRequest.responseText).countries);
for (var i = 0; i < 2 ; i++) {
if (x[i].inv.points > x[i].def.points && c[i]['id'] == x[i].inv['id']) {
console.log( "winnerID: " + x[i].inv.id +"Country Winner is: " + c[i]['name'] + " Country KEY id is: " + c[i]['id'] + " Loser ID is: " + x[i].def.id);
} else if (x[i].inv.points === x[i].def.points) {
console.log(" EQUAL" );
} else {
console.log("DEF WINS");
}
};
};
ourRequest.send();
https://codepen.io/MMan/pen/xPLLKE?editors=1010
@bytao7maobytao7mao sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3711 | @moigithub |http://www.freecodecamp.org/moigithub
bytao7mao sends brownie points to @newnewb :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @newnewb |http://www.freecodecamp.org/newnewb
:trollface: troll problems? notify admins here
dr-d-m sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @padunk |http://www.freecodecamp.org/padunk
action=query
for more options
:point_up: November 14, 2017 3:01 AM @SL0TR - taking a look at your projects. I don't think that I saw the weather project, at least I don't remember seeing one that looked like this. Looks good - but the layout is very sensitive to the viewport height. Perhaps that is what you were referring to with your comment about mobile responsiveness. It looks good, though - one suggestion, on the conversion between F and C, it kind of makes sense to me if the wind speed is also converted from km/h to mi/h? A minor thing, though.
On the wikipedia viewer - I used one of my favorite search words - "potato" and it sort of looks like it didn't order the outputs according to relevance, but the more interesting thing is that each article had the same heading on it "Great Famine (Ireland)" which was also the top article in the list. That seems to hold true for any search - the same heading shows up on all of the articles that are shown. So it seems that the articles are not shown in order of relevance (I think you want to use the "index" value in the returned items) and the title is not being properly set for each article.
isaaknazar sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 902 | @mot01 |http://www.freecodecamp.org/mot01
techmky sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 484 | @github-henry |http://www.freecodecamp.org/github-henry
isaaknazar sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1356 | @sorinr |http://www.freecodecamp.org/sorinr
_getAmount(amount, code) {
if(amount) {
code = code ? code : "USD";
return amount.toLocaleString('en-US', { style: 'currency', currency: code });
}
return 0;
}
let winner = '';
if(inv.points > def.points){
winner = countries[inv.id].name;
} else if(inv.points === def.points){
winner = 'TIE';
} else {
winner = countries[def.id].name;
}
data.append
seahchye sends brownie points to @bankplank and @aizazshahid :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @bankplank |http://www.freecodecamp.org/bankplank
:cookie: 732 | @aizazshahid |http://www.freecodecamp.org/aizazshahid
function wikiLoad(e){
e.preventDefault();
isaaknazar sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1357 | @sorinr |http://www.freecodecamp.org/sorinr
@IsaakNazar be aware that you have to comment out your e.preventDefault() in here:
if (e.keyCode == 13) {
// e.preventDefault();
wikiLoad();
}
otherwise when you hit enter will not work anymore
if (Input.id === "France") {
return countries[def.id].name;
}
document.getElementById("myinputid").value
bytao7mao sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1358 | @sorinr |http://www.freecodecamp.org/sorinr
bytao7mao sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 670 | @longnt80 |http://www.freecodecamp.org/longnt80
var inp = document.getElementById("ss").value;
if (inp === countries[inv.id].name) {
data.append(`
<li>
${countries[inv.id].name}(${inv.points})
vs.
${countries[def.id].name}(${def.points})
-
<strong>
WINNER:
${winner}
</strong>
</li> `);
};
<input type="text" onkeyup="myFunction(e)">
and inside myFunction you place the code you mentioned above but be aware that the first line into the function to be e.preventDefault()
to prevent your form submission
can we assign class to span
suppose
<p> My name is Charles <span class="wheelchair"> Xavier</span> and ..... </p>
input, change, blur...
depending on what functionality you need.
oninput vs onchange
to find out witch one suits best your need
Hii everyone!
Could anyone help me with bootstrapping images in my pen, I tried several options but still images are not in a row (placeholders). Maybe I have some parent/child problem I can't see, help please? :smile:
<div class="col-xs-12 col-md-6">
@media
queries? WIthout anything to look at. And perhaps your error message that gulp is giving you
$width-name: max-width;
$target-width: 320px;
@media screen and ($width-name : $target-width) {
.form-inline .form-control
display: inline-block;
}
{
and }
around display: inline-block
as a quick note.
.form-inline .form-control
selector but there are no curly braces for the content
function truthCheck(collection, pre) {
// Is everyone being true?
// loop through collection in each argument:
for (var i=0; i < (collection.length +1); ) {
// check if the predicate is occuring:
if (i == collection.length) {
return true;
}
else if (i.hasOwnProperty(pre) ) {
i++;
} else
return false;
}
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
screen and ($width-name : $target-widht) { {
. Is there two opening brackets? That will give you that err message
@media screen and ($width-name : $target-width) {
.form-inline .form-control {
display: inline-block;
}
}
$font: 'Inconsolata', monospace;
$white: #fff;
$black: #000;
$yellow: #BB6614;
$uiColor: #a29896;
$footerHoover: #3176B1;
$placeholder: #66AFE9;
$rain: ('../pictures/Rain.jpg');
$snow: ('../pictures/Snow.jpg');
$thunderstorm: ('../pictures/Thunderstorm.jpg');
$snowfall: ('../pictures/Snow.jpg');
$clearsky: ('../pictures/Clear.jpg');
$cloudy: ('../pictures/Clouds.jpg');
$drizzle: ('../pictures/Drizzle.jpg');
$extreme: ('../pictures/Extreme.jpg');
html, body,
margin : 0;
padding: 0;
body
font: 100% $font;
transition: background 1s linear;
.container
max-width: 1200px;
//HEADER
#header
margin-bottom: 10px;
h2
text-align: center;
font-size: 45px;
color: $black;
text-transform: uppercase;
font-weight: bold;
.search_form
margin: 0 auto;
text-align: center;
#search
height: 45px;
&:focus
color: $placeholder;
font-weight: bold;
.btn
width: 120px;
&:hover
background-color: $black;
color: $white;
box-shadow: 0 0 4px 2px rgba(0,0,0,0.3);
transition: all .5s linear;
.get_location
width: 300px;
.ui-autocomplete
background: rgba(0,0,0,0.3);
opacity: 1;
color: $white;
list-style-type: none;
font-size: 16px;
width: 100px;
padding: 2px 5px 0;
font-weight: bold;
//MAIN
#main
color: $white;
.weather_main
width: 40%;
margin-top: 5em;
opacity: 1;
background: rgba(0,0,0,0.3);
padding: 2em;
border-radius: 5px;
font-weight: bold;
.weather_info
width: 33%;
margin-top: 2em;
opacity: 1;
background: rgba(0,0,0,0.3);
font-size: 2em;
padding: 2em;
border-radius: 5px;
font-weight: bold;
float: right;
h1
font-size: 5em;
font-weight: bold;
h3
font-weight: bold;
//FOOTER
#footer
margin-top: 4em;
text-align: center;
font-size: 2.5em;
color: $white;
font-weight: bold;
.footer__hover
color: $white;
&:hover
color: $footerHoover;
transition: all .5s linear;
text-decoration: underline;
&:visited
text-decoration: none;
//MEDIA QUERIES
$width-name: max-width;
$target-width: 320px;
@media screen and ($width-name : $target-width) {
.form-inline .form-control {
display: inline-block;
}
}
collection[i]
first of all
michielhuijse sends brownie points to @mot01 and @onomesotu :sparkles: :thumbsup: :sparkles:
:cookie: 903 | @mot01 |http://www.freecodecamp.org/mot01
:cookie: 292 | @onomesotu |http://www.freecodecamp.org/onomesotu
for(var i=0; i<collection.length; i++) {
stuff here
}
onomesotu sends brownie points to @asjas :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @asjas |http://www.freecodecamp.org/asjas
function truthCheck(collection, pre) {
// Is everyone being true?
// loop through collection in each argument:
for (var i=0; i < (collection.length +1); ) {
// check if the predicate is occuring:
if (i == collection.length) {
return true;
}
else if (i.hasOwnProperty(pre) ) {
i++;
} else
return false;
}
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
function truthCheck(collection, pre) {
// Is everyone being true?
// loop through collection in each argument:
for (var i=0; i < (collection.length +1);) {
// check if the predicate is occuring:
if (i == collection.length) {
return true;
}
else if (collection[i].hasOwnProperty(pre) ) {
i++;
} else
return false;
}
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
i
gets to 4
collection.length
you don't need +1
function truthCheck(collection, pre) {
// Is everyone being true?
// loop through collection in each argument:
for (var i=0; i < collection.length; i++) {
// check if the predicate is occuring:
if (collection[i].hasOwnProperty(pre)===false) {
return false;
}
}
return true;
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
if(!collection[i].pre)
michielhuijse sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
function truthCheck(collection, pre) {
// Is everyone being true?
// loop through collection in each argument:
for (var i=0; i < collection.length; i++) {
// check if the predicate is occuring:
if (collection[i].hasOwnProperty(pre)===false | collection[i][pre]=== null | collection[i][pre] === undefined | collection[i][pre]=== 0 | collection[i][pre]!==collection[i][pre] | collection[i][pre]=== "") {
return false;
}
}
return true;
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
if(collection[i][pre])
.
michielhuijse sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4572 | @masd925 |http://www.freecodecamp.org/masd925
var search = 'france' //or however you get this
results.countries.filter(country => country != search)
country => country.name != search
var inp = document.querySelector("#ss").addEventListener("keyup", myFunction);
if (inp === "France") {
document.write("<h1>Hello World!</h1><p>Have a nice day!</p>");
}
javascript get input value
work.text(timer.text() + ":" + sec.text());
because your span with the id "work" is the parent of your span.timer and span.sec. At least I think that's one problem..parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
Hey everyone, wondering if someone could clarify something for me. I'm on the arguments optional challenge of the intermediate algorithm scripting unit . I've got it to work but not in the way I wanted to. I have created a function that checks to see whether the argument is a number but my original solution didn't work.
original attempt was using isNaN which didn't work the third test case with the args (2, "3") returned '23'
var isNumber = function(num){
return isNaN(num) ? undefined : num;
};
the solution i ended up using was
var isNumber = function(num){
return typeof(num) === 'number' ? num : undefined;
};
why does isNaN()
not provide the same result?
I just can't imagine at this moment how I can implement it, I will be glad to any advice
aws0002 sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @kbaig |http://www.freecodecamp.org/kbaig
ashishbelwal sends brownie points to @mantaselk :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @mantaselk |http://www.freecodecamp.org/mantaselk
display: visible;
- maybe display:block
or display: inline
depending on what you want to do? You should be able to examine the element in the browser devtools and see if you're getting the CSS property changed?
-
I'm guessing it should be fa fa-thumbs-up
Also, you should immediately close your i
element prior to the word Like
have to
submit projects through codepen?
krisb1220 sends brownie points to @asjas :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @asjas |http://www.freecodecamp.org/asjas
raw
link. So once you uploaded it, click on the View Raw
link to open it. You'll then see the normal github url change to raw.githubusercontent.com
. Use that link. It works :)
junipberry sends brownie points to @asjas :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @asjas |http://www.freecodecamp.org/asjas