for(var i=0; i<info[1].length; i++) {
$("#output").append('<div>'+info[1][i]+'</div><div>'+info[2][i]+'</div><br><br>');
}
for(var i=0; i<info[1].length; i++)
this is to loop through the values of info[1]
$("#output").append('<div>'+info[1][i]+'</div><div>'+info[2][i]+'</div><br><br>');
this is to insert the values inside info[1]
into some html tags (to display on the page), and append
is to place that content after each other inside the div $output
$.ajax({
url: url,
success: function(info) {
console.log(searchInput);
console.log(info);
for(var i=0; i<info[1].length; i++) {
$("#output").append('<div>'+info[1][i]+'</div><div>'+info[2][i]+'</div><br><br>');
}
}
});//ajax
});//on click
});//end doc ready
for(var x=0; x<info[1].length; x++) {
$("#output").append('<div>'+info[1][x]+'</div><div>'+info[2][x]+'</div><br><br>');
}
@longnt80
Is anyone familiar with the syntax on the left-hand side: const {error, value} = Joi.validate({ a: 'a string' }, schema);
Anyone know if this is an ES6 syntax thing? I'm not sure if that, or just a Joi library thing...
info[1]
should be an array
info[1]
access the related terms list array
i
in the loop will loop through each item in those two arrays
for(var j=0; j<url[1].length; j++)
ismailhozain sends brownie points to @just1witness and @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 549 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 336 | @just1witness |http://www.freecodecamp.com/just1witness
function convertHTML(str) {
return str.replace(/[^\w\s]/gi, function(){
if (str.indexOf('&')){
return '&';
} else if (str.indexOf('<')){
return '<';
}
});
}
convertHTML("Hamburgers < Pizza < Tacos”);
nvm my last question lol got it work but now this is my concern
function convertHTML(str) {
return str.replace(/[^\w\s]/gi, function(){
if (str.indexOf('&') != -1){
return '&';
} else if (str.indexOf('<')!= -1){
return '<';
} else if (str.indexOf('>')!= -1){
return '>';
} else if (str.indexOf('"')!= -1){
return '"';
} else if (str.indexOf("'")!= -1){
return ''';
}
});
}
convertHTML("<>”);
I dont understand why this . ”<>”
does not pass the test, when those characters passed other test they were in.
these two passed "Hamburgers < Pizza < Tacos” & "Sixty > twelve”
it returns this <<
so when I switch it around like this
function convertHTML(str) {
return str.replace(/[^\w\s]/g, function(){
if (str.indexOf('&') != -1){
return '&';
} else if (str.indexOf('>')!= -1){
return '>';
} else if (str.indexOf('<')!= -1){
return '<';
} else if (str.indexOf('"')!= -1){
return '"';
} else if (str.indexOf("'")!= -1){
return ''';
}
});
}
convertHTML("<>”);
it now returns this >>
?? whats going on lol
rafaelmonroy sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @x140hu4 |http://www.freecodecamp.com/x140hu4
I'm doing my FCC certification with a friend designer.
She takes care of the UX / UI, and i code.
We are both doing it to improve our skills in our fields, so any constructive feedback we ll be appreciated from us :)
Here's our wikipedia viewer
https://koop4.github.io/wikipediaViewer/
morched23mj sends brownie points to @borisyordanov :sparkles: :thumbsup: :sparkles:
:cookie: 361 | @borisyordanov |http://www.freecodecamp.com/borisyordanov
Hey, all, I’m working on the Wikipedia viewer and I’m trying to understand the API. Is this could sufficient to retrieve the object…
$.getJSON ("https://en.wikipedia.org/w/api.php?action=query&format=json&prop=&list=search&srsearch=achilles", function (json) {
$(“#tester").html("SUCCESS");
});
I’m assuming not because the #tester element isn’t changing.
position: absolute
on the header
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&prop=&list=search&srsearch=achilles. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not al
lowed access.
trev-of-ev sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 849 | @mot01 |http://www.freecodecamp.com/mot01
“The ? on the end of the URL tells jQuery that it’s dealing with a JSONP request instead of JSON. jQuery then automatically registers the callback function which it calls when the request retruns.”
imperial-isms sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 850 | @mot01 |http://www.freecodecamp.com/mot01
position: absolute
to position: relative;
in the header class
Hey everyone, I'm working on the twitch project and am stuck. Does anyone know why this snippet to get get offline users doesn't work? I'm trying to use to $.getJSON calls to do this. I use the first call to check if the user is online. The second, I have use another page path to get that user's display name. function getOfflineList(){
//FOUR LOOP TO CYCLE THROUGH ARRAY OF USERS
for (var u = 0; u < usernames.length; u++) {
streamUrl = "https://wind-bow.glitch.me/twitch-api/streams/" + usernames[u] + "/?callback=?";
//GET JSON TO CHECK IF OFFLINE
$.getJSON(streamUrl, function(data1){
if (data1.stream===null) {
userUrl = "https://wind-bow.glitch.me/twitch-api/channels/" + usernames[u] + "/?callback=?";
//IF NULL GET DISPLAY NAME FROM ENDPOINT USERS
$.getJSON(userUrl, function(json){
console.log(json.display_name);
});
}
});
}
}
getOfflineList();
var
with let
in your for loop.
function getOfflineList() {
//FOUR LOOP TO CYCLE THROUGH ARRAY OF USERS
usernames.forEach(function(user, u) { // or for (let u = 0; u < usernames.length; u++) {
streamUrl = "https://wind-bow.glitch.me/twitch-api/streams/" + usernames[u] + "/?callback=?";
//GET JSON TO CHECK IF OFFLINE
$.getJSON(streamUrl, function(data1) {
if (data1.stream === null) {
userUrl = "https://wind-bow.glitch.me/twitch-api/channels/" + usernames[u] + "/?callback=?";
//IF NULL GET DISPLAY NAME FROM ENDPOINT USERS
$.getJSON(userUrl, function(json) {
console.log(json.display_name);
});
}
});
}) // end forEach(), remove closing parenthesis if using for loop instead
}
:cookie: 88 | @piteto |http://www.freecodecamp.com/piteto
janelledement sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
janelledement sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 851 | @mot01 |http://www.freecodecamp.com/mot01
url
url
url
undefined
undefined...
../images/tiles/image.png
..
goes up a level
&callback=?
to the end of the url
&origin=*
in your URL: https://stackoverflow.com/a/38921370
feldbot sends brownie points to @piteto and @orangekulture and @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 89 | @piteto |http://www.freecodecamp.com/piteto
:cookie: 852 | @mot01 |http://www.freecodecamp.com/mot01
:cookie: 462 | @orangekulture |http://www.freecodecamp.com/orangekulture
amitp88 sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 853 | @mot01 |http://www.freecodecamp.com/mot01
drawTile()
janelledement sends brownie points to @piteto and @mot01 :sparkles: :thumbsup: :sparkles:
janelledement sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
let
)
https://codepen.io/moT01/pen/QqLOWB
var
- but I guess in this case, var
helped with learning something new :)
janelledement sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 472 | @korzo |http://www.freecodecamp.com/korzo
// Setup
function phoneticLookup(val) {
var result = "";
// Only change code below this line
result = lookup[val];
var lookup = {
alpha: "Adams",
bravo: "Boston",
charlie: "Chicago",
delta: "Denver",
echo: "Easy",
foxtrot: "Frank"
};
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
lookup
before it is defined @wnghero
@moT01 I was thinking of that too, but I figured the code on line 314
// Calculate the tile coordinates
var coord = getTileCoordinate(i, j, 0, (animationtime / animationtimetotal) * shift);
took care of that
wnghero sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 90 | @piteto |http://www.freecodecamp.com/piteto
trev-of-ev sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1333 | @sorinr |http://www.freecodecamp.com/sorinr
janelledement sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 854 | @mot01 |http://www.freecodecamp.com/mot01
});
janelledement sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
keyboard.$el.trigger('input')
alecx4 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 92 | @piteto |http://www.freecodecamp.com/piteto
keyboard.$el.onchange();
@AleCx4
alecx4 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
kowalatam sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 93 | @piteto |http://www.freecodecamp.com/piteto
box-sizing: border-box
will include content, border, and padding in the width. It makes it easier to size your elements.
engjell00 sends brownie points to @feldbot and @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 94 | @piteto |http://www.freecodecamp.com/piteto
:cookie: 298 | @feldbot |http://www.freecodecamp.com/feldbot