:star2: 1368 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
xemexpress sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
Since the Java help channel is pretty much dead would someone be willing to help me out?
If someone could confirm or deny my understanding of this I would be incredibly grateful.
function largestOfFour(mainArray) {
return mainArray.map(function (subArray){
return subArray.reduce(function (previousLargestNumber, currentLargestNumber) {
return (currentLargestNumber > previousLargestNumber) ? currentLargestNumber : previousLargestNumber;
}, 0);
});
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
There are a couple methods in there I partially understand and wish to confirm. So the Map method takes the targeted Array or Subs and combines them into one main Array, and allows it to then be targeted with a function and named within that function as sub-array. Reduce says that all of the following function will be aimed at taking multiple numbers, and taking them down to one, then the function is a new way of writing an if/else statement?
function largestOfFour(mainArray) {
return mainArray.map(function (subArray) {
console.log('map method returned: ', subArray);
return subArray.reduce(function (previousLargestNumber, currentLargestNumber) {
console.log('reduce method returned: ', previousLargestNumber, currentLargestNumber);
return (currentLargestNumber > previousLargestNumber) ? currentLargestNumber : previousLargestNumber;
}, 0);
});
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
corycmyers sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1369 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
var boo = myArray.map( subA => Math.max(...subA) )
- you'd have to put that in a function.
#
in front of IDs in jQuery
$(window).scroll(function() {});
swong194 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1370 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Hey can someone help me figure out what's wrong with my ajax request for the wikipedia viewer? the API documentation doesn't seem very straightforward
$.ajax( {
url: query,
data: "?action=query&list=search&srsearch=" + encodeURI(input) +"&origin=*&utf8=",
dataType: 'json',
type: 'GET',
headers: { 'Api-User-Agent': 'Example/1.0' },
success: function(data) {
$("#test").html(data);
}
});
Regarding the bottom part of this portfolio: https://codepen.io/freeCodeCamp/full/YqLyXB
How the grey bar is made?
&format=json
to your url. Also, the data:
property of your ajax call should not start with a ?
data: "action=query&list=search&format=json&srsearch=" + encodeURI(input) +"&origin=*&utf8=",`
data-toggle="modal" data-target="#myModal"
- but all your modals have different IDs to use as targets
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<img class="showimage img-responsive" src="" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
rallph sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1371 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
$("#test").html(JSON.stringify(data));
rallph sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:warning: rallph already gave tylermoeller points
amitp88 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1372 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
cfunkles sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1373 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
pageid
value - maybe you can derive the URL from that - tack that on to some value? Check the API docs...
Well when I make a request with the search term "Philosophy" with this url
https://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=%22Philosophy%22&origin=*&utf8=
this is an example of one of the results
{
"ns": 0,
"title": "Interpretation (philosophy)",
"size": 3759,
"wordcount": 420,
"snippet": "only insofar as these scientific models are true. Philosophical theory http://classof1.com/homework_answers/<span class=\"searchmatch\">philosophy</span>/aesthetics_interpretation/",
"timestamp": "2016-11-15T23:11:41Z"
}
http://en.wikipedia.org/?curid= [id here]
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=images&titles=San_Francisco&imlimit=20
does return the ID values, and it looks like @mrslwiseman shows how to use the ID to get the article.
:cookie: 215 | @mrslwiseman |http://www.freecodecamp.com/mrslwiseman
rallph sends brownie points to @mrslwiseman and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2340 | @khaduch |http://www.freecodecamp.com/khaduch
function dropElements(arr, func) {
// Drop them elements.
for(var i=0;i<arr.length;i++){
if(func(arr[0])){
}else{
arr.shift();
}
}
return arr;//[3,4]
}
dropElements([1, 2, 3, 4], function(n) {return n > 5;}) ;
[3, 4]
for this, not with that filtering function and that input array. Is this code even running? I might think that using the length of the arr
variable while also modifying the arr
variable with arr.shift()
could be a bad thing to do?
i
is probably then holding a value of 2 so it stops.
action
attribute?
fortmaximus sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1374 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
#navigation {display: flex;}
for(var i=1;i<object.length;i++){
console.log(object[i]);
}
shenoyabhijith sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1128 | @sorinr |http://www.freecodecamp.com/sorinr
chaitanya009 sends brownie points to @winroy :sparkles: :thumbsup: :sparkles:
:cookie: 120 | @winroy |http://www.freecodecamp.com/winroy
bwongcodes sends brownie points to @heydante :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @heydante |http://www.freecodecamp.com/heydante
mee0wth sends brownie points to @oppiniated :sparkles: :thumbsup: :sparkles:
:cookie: 518 | @oppiniated |http://www.freecodecamp.com/oppiniated
mee0wth sends brownie points to @heydante :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @heydante |http://www.freecodecamp.com/heydante
!--Modaal-->
<button type="button"class="btn btn-success btn-lg" data-toggle="modal" data-target="#mymodal">Rules</button>
<div id="mymodal" class="modal fade" role="dialog">
<div class = "modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Rules</h4>
</div>
<div class="modal-body">
<ol class="text-center">
<li> You can play either strict or simple by pressing (start button)</li>
<li> After loosing refresh the page to play again.</li>
<li> Just select the current highlighted button when playing in start mode.</li>
<li> Enjoy. </li>
</ol>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!---->
Where am i doing wrong?
So after that one year struggle finally i have completed the front end certification program by FCC.Although i am weak in JS but i will try to make myself better through books.
Special Thanks to:
@sorinr @sjames1958gm @Mr-Kumar-Abhishek @devopsec @danydin
My last project is almost a bit terrible but i would come back to make it more better and reduce the code.
Thank you FCC.
@camperbot Thanks.
mohammadhasham sends brownie points to @sorinr and @sjames1958gm and @mr-kumar-abhishek and @devopsec and @danydin and @camperbot :sparkles: :thumbsup: :sparkles:
:cookie: 486 | @mr-kumar-abhishek |http://www.freecodecamp.com/mr-kumar-abhishek
:cookie: 334 | @danydin |http://www.freecodecamp.com/danydin
:star2: 2924 | @camperbot |http://www.freecodecamp.com/camperbot
:star2: 1129 | @sorinr |http://www.freecodecamp.com/sorinr
:cookie: 310 | @devopsec |http://www.freecodecamp.com/devopsec
:star2: 5486 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
app.weatherWidget
<div ng-app="app.weatherWidget" ng-controller="WeatherCtrl">
<div id="weather">
</div>
</div>
VM61 angular.min.js:101 GET https://api.darksky.net/forecast/6917180f67b1c2ccf5b5c10e9423388b/,?units=a…=alerts,daily,flags,hourly,minutelyundefined&callback=angular.callbacks._0 404 (Not Found)
though
https
in the url to codepen
@sbxn14 You missed that the callback to the current position delivers an object which is bit deeper as you used.
darkSky.getCurrent(position.coords.latitude, position.coords.longitude)
Put that instead ofdarkSky.getCurrent(position.latitude, position.longitude)
:cookie: 741 | @alpox |http://www.freecodecamp.com/alpox
sbxn14 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
kd158 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 742 | @alpox |http://www.freecodecamp.com/alpox
vasilebotnaru sends brownie points to @sbxn14 :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @sbxn14 |http://www.freecodecamp.com/sbxn14
var requestString = "https://api.darksky.net/forecast/" + apiKey + "/" + latitude + "," + longitude;
$.getJSON(requestString, function(response) {
console.log(response);
});
.then(function( data ){
// populate ur $scope variables from data object
})
vasilebotnaru sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2580 | @moigithub |http://www.freecodecamp.com/moigithub
vasilebotnaru sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 743 | @alpox |http://www.freecodecamp.com/alpox
:cookie: 344 | @mohammadhasham |http://www.freecodecamp.com/mohammadhasham
mohammadhasham sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2581 | @moigithub |http://www.freecodecamp.com/moigithub
navigator.geolocation.getCurrentPosition
callback, do this
var latlng = new google.maps.LatLng(lat, lng); // lat will be your latitude and lng will be your longitude
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log(results)
}
});
var geocoder
as a public variable that is declared at the beginning of your script
setInterval()
s one for each clock hand?
initMap
@UsamaHameed
I can't use multiple setIntervals in JS right? @adityaparab Single threaded language!!!
You might!
the display function doesnt work
$content
?
but i spent so much time trying to make this one to work..
welcome to programming. Say good bye to certainty (as long as youre learning/researching) :)
&callback=JSON_CALLBACK
in your $http
?
mohammadhasham sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1131 | @sorinr |http://www.freecodecamp.com/sorinr
JSON_CALLBACK
is a function that Angular defines internally to receive padded json data
JSON_CALLBACK
with your custom function.
function steamrollArray(arr) {
var flattenedArray = [];
// Create function that adds an element if it is not an array.
// If it is an array, then loops through it and uses recursion on that array.
var flatten = function(arg) {
if (!Array.isArray(arg)) {
flattenedArray.push(arg);
} else {
for (var a in arg) {
flatten(arg[a]);
}
}
};
// Call the function for each element in the array
arr.forEach(flatten);
return flattenedArray;
}
// test here
steamrollArray([1, [2], [3, [[4]]]]);
in this solution of steamroller what is the significance of arr.forEach(flatten);
steamrollArray(arg[a])
instead of flatten(arg[a]);
?
arr.forEach(flatten);
arg
i.e; array so what is the point of doing so?@MohammadHasham
var flatten = function(arg) {
if (!Array.isArray(arg)) {
flattenedArray.push(arg);
} else {
for (var a in arg) {
flatten(arg[a]);
}
}
};
// Call the function for each element in the array
arr.forEach(flatten);
is as good as saying
arr.forEach(function flatten(arg) {
if (!Array.isArray(arg)) {
flattenedArray.push(arg);
} else {
for (var a in arg) {
flatten(arg[a]);
}
}
});
return flattenedArray;
mohammadhasham sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 882 | @adityaparab |http://www.freecodecamp.com/adityaparab
but we are already passing the
arg
i.e; array so what is the point of doing so?
applying forEach to the array
Can you tell me the control flow of program?
but the arg
doesn't get passed on it's own, right? forEach will pass the arg
to flatten
function steamrollArray(arr) {
return Array.isArray(arr) ? Array.prototype.concat.apply([],arr.map(steamrollArray)):[arr];
}
steamrollArray([1, [2], [3, [[4]]]]);
:[arr]
are redundant in this example
function steamrollArray(arr) {
return Array.isArray(arr) ? Array.prototype.concat.apply([],arr.map(steamrollArray)):arr;
}
steamrollArray([1, [2], [3, [[4]]]]);
flatten
@shenoyabhijith
but then again i feel like i wanna learn how to do
never ever give up
how do you learn
by pushing through the bullshit that comes to your mind, bullshit like when you dont know anything
i don't know how to walk... i don't know how to walk... i don't know how to walk...
shenoyabhijith sends brownie points to @mohammadhasham :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @mohammadhasham |http://www.freecodecamp.com/mohammadhasham
var app = angular.module('Weather', []);
app.factory('WeatherWdiget'
< typo ? @sbxn14app.controller('WeatherCtrl', function($scope, WeatherWidget)
<
Mixed Content: The page at 'https://codepen.io/sbxn14/pen/apmJJQ?editors=1010' was loaded over HTTPS, but requested an insecure script 'http://ipinfo.io/json?callback=angular.callbacks._0'. This request has been blocked; the content must be served over HTTPS.
h
is not a standard html tag, as far as I remember
shenoyabhijith sends brownie points to @mohammadhasham :sparkles: :thumbsup: :sparkles:
:warning: shenoyabhijith already gave mohammadhasham points
$.geJSON
and your URL needs to start with http://
aenila sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1377 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
$.ajaxSetup({cache: false});
pkaretas sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1378 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
background-size: cover;
background-position: center center;
bestintown23 sends brownie points to @jdtdesigns :sparkles: :thumbsup: :sparkles:
:cookie: 875 | @jdtdesigns |http://www.freecodecamp.com/jdtdesigns
$$$$
solves
var cache = console.log(name);
?
Can someone please help me with my page? 💐 https://codepen.io/CMYK/pen/bgqOxG?editors=1100
How can I move all my thumbnails, pictures, text, (everything!) to the left?
I'm trying to divide the whole webpage in two and make a new column/ thumbnail on my right.
I've tried sticking pull-left in every class I could think of, but nothing works! 😟
Help?
html
or body
tag into it.json
variable with the sample code he gave: :point_up: January 23, 2017 11:16 AM
@PerpetualWar In that example code, all your Weather Object is in the 'json' variable:
$.getJSON("apiurl", function(json) {
// weather data is stored in a variable named 'json'
});
You can name it whatever you want, really:
$.getJSON("apiurl", function(weatherData) {
// weather data is stored in a variable named 'weatherData'
});
:warning: perpetualwar already gave tariellaelius points
&
in front of the lon
parameter in your Weather API URL: "&lon="
:star2: 1381 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
perpetualwar sends brownie points to @tylermoeller and @tariellaelius :sparkles: :thumbsup: :sparkles:
mortiferr sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1382 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
tylermoeller sends brownie points to @dovroc and @yourname :sparkles: :thumbsup: :sparkles:
:cookie: 130 | @dovroc |http://www.freecodecamp.com/dovroc
:warning: could not find receiver for yourname
josie-n sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 744 | @alpox |http://www.freecodecamp.com/alpox
josie-n sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1383 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
pull-left
is the way to go here. Columns stack from left to right, so you can put your columns in a row and choose the size you want as you stack them to the right.
josie-n sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:warning: josie-n already gave tylermoeller points
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
if (contacts[i].firstName){
if (contacts[i].prop){
return contacts[i].prop;
}else return "No such contact";
}else return "No such property";
}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
How do I make "Kristian", "lastName" return "Vos"?
for(var i=0;i<contacts.length;i++){
if (contacts[i][firstName]){
if (contacts[i][prop]){
return contacts[i][prop];
}else return "No such contact";
}else return "No such property";
}
window.open
and twitter url in it
@jdtdesigns
for(var i=0;i<contacts.length;i++){
if (contacts[i].firstName==firstName){
if (contacts[i][prop]){
return contacts[i][prop];
}else return "No such property";
}else return "No such contact";
}
Still, tho, not all the requirements are met.
.
.attr("href", "http link");
got it.. nice approach :+1:
hello911 sends brownie points to @jdtdesigns :sparkles: :thumbsup: :sparkles:
:cookie: 876 | @jdtdesigns |http://www.freecodecamp.com/jdtdesigns
I'm working on my random quote machine and it works great UNTIL I double click on the 'New Quote' button. :worried: Instead of clearing previous quotes, it appends to it. Any help is appreciated. Thanks!
$(".quote").html("");
$(".author").html("");
.empty()
: https://api.jquery.com/empty/
Hi there is there a way to make all thumbnails the same height?
jchiang7874 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1385 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
detour26 sends brownie points to @armynational :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for armynational
mariogalindov sends brownie points to @tylermoeller and @asparism :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @asparism |http://www.freecodecamp.com/asparism
:star2: 1386 | @tylermoeller |http://www.freecodecamp.com/tylermoeller