@kmulligan @mutantspore I got this error in Firefox:
16:03:52.695 Content Security Policy: The page's settings blocked the loading of a resource at self ("script-src http://codepen.io 'unsafe-eval' http://preprocessor.codepen.io http://*.pubnub.com https://*.pubnub.com http://platform.twitter.com http://connect.facebook.net http://www.google-analytics.com https://*.google-analytics.com https://*.google.com http://wufoo.com https://wufoo.com http://*.wufoo.com https://*.wufoo.com https://*.stripe.com https://*.instapaper.com http://*.instapaper.com http://dc8na2hxrj29i.cloudfront.net http://s3.buysellads.com http://srv.buysellads.com/ https://www.fullstory.com https://stats.buysellads.com http://stats.buysellads.com https://*.braintreegateway.com https://www.paypalobjects.com http://assets.codepen.io http://assets.codepen.io/ https://assets.codepen.io https://assets.codepen.io/ http://assets.cdpn.io").1 bEJENN
And this similar one in Chrome:
Refused to load the script 'data:application/javascript;base64,KGZ1bmN0aW9uKCkgewogICAgLy8gaHR0cHM6Ly9k…ogICAgZ2EucmVtb3ZlID0gbm9vcGZuOwogICAgd2luZG93W2dhTmFtZV0gPSBnYTsKfSkoKTs=' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' http://preprocessor.codepen.io http://*.pubnub.com https://*.pubnub.com http://platform.twitter.com http://connect.facebook.net http://www.google-analytics.com https://*.google-analytics.com https://*.google.com http://wufoo.com https://wufoo.com http://*.wufoo.com https://*.wufoo.com https://*.stripe.com https://*.instapaper.com http://*.instapaper.com http://dc8na2hxrj29i.cloudfront.net http://s3.buysellads.com http://srv.buysellads.com/ https://www.fullstory.com https://stats.buysellads.com http://stats.buysellads.com https://*.braintreegateway.com https://www.paypalobjects.com http://assets.codepen.io http://assets.codepen.io/ https://assets.codepen.io https://assets.codepen.io/ http://assets.cdpn.io".
owentemp sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1137 | @mutantspore | http://www.freecodecamp.com/mutantspore
wyattwade sends brownie points to @fuzyon :sparkles: :thumbsup: :sparkles:
:star: 179 | @fuzyon | http://www.freecodecamp.com/fuzyon
kwhms sends brownie points to @kmulligan :sparkles: :thumbsup: :sparkles:
:star: 281 | @kmulligan | http://www.freecodecamp.com/kmulligan
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
@DivaWeb do i past all of this <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<h1 class="text-center"> Kevin Stauferland's Portfolio </h1>
wyattwade sends brownie points to @divaweb :sparkles: :thumbsup: :sparkles:
:star: 216 | @divaweb | http://www.freecodecamp.com/divaweb
function weatherIcon() {
var icon = $(updateWeather.weather[0].icon);
$("#icon").append("<img src='http://openweathermap.org/img/w/" + icon + ".png'>");
}
andrewchar sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1138 | @mutantspore | http://www.freecodecamp.com/mutantspore
@KevinStaufy <!Doctype html>
<html>
<head>
//add libraries here//
<title>name of page<title>
</head>
<body>
//add what you want on your web page here.
</body>
</html>
kevinstaufy sends brownie points to @divaweb :sparkles: :thumbsup: :sparkles:
:star: 217 | @divaweb | http://www.freecodecamp.com/divaweb
@RobMo check out this section on bootstrap Component alignment
Align nav links, forms, buttons, or text, using the .navbar-left or .navbar-right utility classes. Both classes will add a CSS float in the specified direction. For example, to align nav links, put them in a separate <ul> with the respective utility class applied.
These classes are mixin-ed versions of .pull-left and .pull-right, but they're scoped to media queries for easier handling of navbar components across device sizes.
Right aligning multiple components
Navbars currently have a limitation with multiple .navbar-right classes. To properly space content, we use negative margin on the last .navbar-right element. When there are multiple elements using that class, these margins don't work as intended.
We'll revisit this when we can rewrite that component in v4.
Working on Random Quote Machine, stuck trying to get the giant quotes into the javascript like the example. I was able to do it easily when it wasn't with the text. I just want the ion-quote to be in there but I'm not sure how to do it.
<h2 id="quote"><i class="ion-quote quotes-icon"></i>Every collection of quotes has to start somewhere!</h2></div>
$("#quote").text(quotes[rand2]);
That's the html and the javascript, I tried using + inside the text function but no dice
quotes[rand2]
isn't accessing what you want it to
andrewchar sends brownie points to @jayuhasz :sparkles: :thumbsup: :sparkles:
:star: 296 | @jayuhasz | http://www.freecodecamp.com/jayuhasz
Finally fixed it up a bit. At least that one chunk of code. Couldn't have done it without you thanks again man @h4r1m4u . Have a good night
@wyattwade excellent, glad to hear that; nice work! you're most welcome
sorry h4r1m4u, you can't send brownie points to yourself! :sparkles: :sparkles:
:star: 254 | @wyattwade | http://www.freecodecamp.com/wyattwade
format=jsonp
instead of adding the callback parameter?
format=jsonp
parameter. the point i was making is that "So what the call back function does is, it prevents the statement from executing until all the data is fetched from the API call." is not quite a correct explanation of the callback parameter
davidsonsteve sends brownie points to @batilc1 :sparkles: :thumbsup: :sparkles:
:star: 209 | @batilc1 | http://www.freecodecamp.com/batilc1
hello guys, am working on the pomodoro and this is how am thinking of tackling the project
1.have two global variable, break time and session time in secs
create functions that increases and decreases length of session and break and updates the new time when clicked
functions that starts session time and break time count by getting the time updated by the functions above and start a countdown on it
use a function to toggle between the 2 modes using a boolean to indicate when session is running and if done start break session
5.a function to pause the event using clearInterval.
That's what I can think of , thanks for your time
lumexralph sends brownie points to @mutantspore and @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1420 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
:star: 1142 | @mutantspore | http://www.freecodecamp.com/mutantspore
timeCount()
just won’t reach to 0 before ended and switched into breakInterval
. Would really appreciate any help from anyone who’ve cleared this task. :smile: var break_length;
var session_length;
var minutes;
var interval;
var breakInterval;
var seconds = 0;
function increaseBreak(break_length) {
break_length++;
$('#break').html(break_length);
return break_length;
}
function decreaseBreak(break_length) {
break_length--;
if (break_length < 1) {
break_length = 1;
}
$('#break').html(break_length);
return break_length;
}
function increaseSession(session_length) {
session_length++;
$('#session').html(session_length);
$('#total').html(session_length);
return session_length;
}
function decreaseSession(session_length) {
session_length--;
if (session_length < 1) {
session_length = 1;
}
$('#session').html(session_length);
$('#total').html(session_length);
return session_length;
}
function countdownCtrl() {
if (seconds === 0) {
minutes--;
seconds = 59;
} else {
seconds--;
}
// Executing timeCount();
(function timeCount() {
if (minutes === 0 && seconds === 0) {
clearInterval(interval);
if (break_length) {
breakInterval = setInterval(breakcountCtrl, 1000);
}
} else {
$('#total').html(minutes + ":" + (seconds < 10 ? "0" : "") + String(seconds));
}
})();
function breakcountCtrl() {
$('#total').html(break_length--);
}
}
$(document).ready(function() {
break_length = parseInt($('#break').text());
session_length = parseInt($('#session').text());
minutes = session_length;
$('#ibl').click(function() {
break_length = increaseBreak(break_length);
});
$('#dbl').click(function() {
break_length = decreaseBreak(break_length);
});
$('#ise').click(function() {
session_length = increaseSession(session_length);
minutes = session_length;
});
$('#dse').click(function() {
session_length = decreaseSession(session_length);
minutes = session_length;
});
$('#total').click(function() {
if (interval) {
clearInterval(interval);
interval = undefined;
} else {
interval = setInterval(countdownCtrl, 50);
}
});
});
jovjohnson sends brownie points to @hman1911 :sparkles: :thumbsup: :sparkles:
:star: 85 | @hman1911 | http://www.freecodecamp.com/hman1911
$(document).ready(function() {
function spinnerChange(event) {
//this function gets called when the spinner value chages.
//your code here :)
}
$('input[name=quantity]').on("click",function() {
var button = $(this).closest(".quant");
var price = button.data("price");
price = parseFloat(price);
var num = $("input[type=number]").val();
var total = (num * price).toFixed(2);
var totalPrint = $('<p class="total">($' + total + ' TOTAL)</p>');
if(num >= 2){
$('.price').find('.total').html(totalPrint);
}
});
$(document).ready(function() {
$('input[name=quantity]').on("click",function() {
var price = $(this).data("price");
price = parseFloat(price);
var num = $(this).val();
var total = (num * price).toFixed(2);
if(num >= 2){
$(this).closest('.row').find('.total').text("($" + total + " TOTAL)");
}
});
});
with the reset button anyone httpcodepeniocodernoobpenvlmywneditors1010
jovjohnson sends brownie points to @hman1911 :sparkles: :thumbsup: :sparkles:
:warning: jovjohnson already gave hman1911 points
<div class="row text-center">
<a href="www.twitter.com" target="_blank" class="btn btn-default btn-lg "><i class="fa fa-twitter fa-fw"></i>Twitter</a>
<a href="www.twitter.com" target="_blank" class="btn btn-default btn-lg "><i class="fa fa-linkedin fa-fw"></i>LinkedIn</a>
<a href="www.twitter.com" target="_blank" class="btn btn-default btn-lg"><i class="fa fa-github fa-fw"></i>GitHub</a>
<a href="www.freecodecamp.com" target="_blank" class="btn btn-default btn-lg"><i class="fa fa-fire fa-fw"></i>FreeCodeCamp</a>
</div>
adhok sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1421 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
$(document).ready(function() {
$('input[name^=quantity]').on("click",function() {
var button = $(this).closest(".quant");
var price = button.data("price");
price = parseFloat(price);
var num = $("input[type=number]").val();
var total = (num * price).toFixed(2);
var totalPrint = $('<p id="total">($' + total + ' TOTAL)</p>');
if(num >= 2){
$('.price').find('.total').html(totalPrint);
}
});
something like that anyway @h4r1m4u
$(document).ready(function() {
$('input[name^=quantity]').on("click",function() {
var button = $(this).closest(".quant"); // not needed; you're already clicking on the input which contains the price in the data-price attribute, hence you can simply use "this"
var price = button.data("price");
price = parseFloat(price);
var num = $("input[type=number]").val(); // similar to the above. it's the same input element, "this" suffices
var total = (num * price).toFixed(2);
// here you're using the jQuery selector $(), but the selector doesn't make much sense. selector should generally be a the element, class, id or combination of thereof
// i'm assuming that what you meant to do here is to construct the string for the total price. if that's the case, you'd do it without the $() selector
var totalPrint = $('<p id="total">($' + total + ' TOTAL)</p>');
if(num >= 2){
// the problem with the $('.price') selector is that it's the same in all the 3 boxes (each box has a .price paragraph). so even if you're changing
// the qty in the 3rd box, it'll rewrite the total price in the first box. we need to somehow tie it to changing the price only in the box where we're
// changing the qty - which is where "this" comes into play again
$('.price').find('.total').html(totalPrint);
}
});
kaizen711 sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1422 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
kaizen711 sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:warning: kaizen711 already gave h4r1m4u points
timeCount()
just won’t reach to 0
before clearInterval()
and switched into breakInterval
. Would really appreciate any help from anyone who’ve cleared this task. :smile:direction: rtl;
on .calculator input[type='text']
in your CSS. 'rtl' stand for right to left. instead, use text-align: right;
Sorry guys, today I know I am tremendously annoying, but I cannot fix those litle things.
http://codepen.io/DiazPedroAbel/pen/pgRXWv
I want to put a background in my calculator webpage, so I change it from the body background but it makes something weird. Looks like its broken in 3 pieces or rows...
abel1987 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 880 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
abel1987 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: abel1987 already gave wearenotgroot points
abel1987 sends brownie points to @pringon :sparkles: :thumbsup: :sparkles:
:star: 242 | @pringon | http://www.freecodecamp.com/pringon
@rusaym When you call new Vehicle, the constructor of car will actually lead to Vehicle, which people think means 'was constructed by'. It actually doesn't mean that at all. Prototypal inheritance is a complicated concept, and is very different to class based inheritance. I recommend reading this free book for a great explanation:
https://github.com/getify/You-Dont-Know-JS/tree/master/this%20%26%20object%20prototypes
But regarding your question, you don't need to include that line at all for what you are doing.
rusaym sends brownie points to @hman1911 :sparkles: :thumbsup: :sparkles:
:star: 86 | @hman1911 | http://www.freecodecamp.com/hman1911
dshgna sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 483 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 881 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: dshgna already gave wearenotgroot points
@dshgna would look like this
$(document).ready(function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var key = "6fccda1c30c7f392d44016c2bb3b6519";
var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&APPID=" + key;
$.getJSON(url, function(data) {
var temp_celsius = data.main.temp;
var country = data.sys.country;
var city = data.country;
var weather = data.weather.main;
console.log(temp_celsius);
console.log(country);
console.log(data);
console.log(weather);
});
});
}
});
or
function start(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var key = "6fccda1c30c7f392d44016c2bb3b6519";
var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&APPID=" + key;
$.getJSON(url, function(data) {
var temp_celsius = data.main.temp;
var country = data.sys.country;
var city = data.country;
var weather = data.weather.main;
console.log(temp_celsius);
console.log(country);
console.log(data);
console.log(weather);
});
});
}
}
start();
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: dshgna already gave wearenotgroot points
@dshgna then jsut append the url -------->http://openweathermap.org/img/w/'+iconname+'.png'
use this as source in <img scr=>
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: dshgna already gave wearenotgroot points
function countDownFrom(seconds) {
if (playing) {
if (seconds > -1) { //<-----------------culprit should be 0
setTimeout(function() {
counterValue = countDownFrom(seconds = seconds - 1)
renderTime(seconds);
}, 1000);
} else {
playing = false;
seconds = 0;
}
}
return seconds;
}
fattone225 sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1424 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
savrov sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1425 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
avanbox sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1426 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
thomas-duval sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1427 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
annaslab sends brownie points to @rune-jacobsen :sparkles: :thumbsup: :sparkles:
:star: 287 | @rune-jacobsen | http://www.freecodecamp.com/rune-jacobsen
annaslab sends brownie points to @jnmorse :sparkles: :thumbsup: :sparkles:
:star: 393 | @jnmorse | http://www.freecodecamp.com/jnmorse
hintcj sends brownie points to @dickfink and @avanbox :sparkles: :thumbsup: :sparkles:
:star: 208 | @avanbox | http://www.freecodecamp.com/avanbox
:star: 168 | @dickfink | http://www.freecodecamp.com/dickfink
@cesarrodas You’re going to have to detect the scroll position of your page and the (vertical) position of the sections on your page, and then based on that, give the corresponding menu item in your menu a specific class.
http://api.jquery.com/scrollTop/
http://api.jquery.com/position/
Something like this (not tested):
if ( $('body').scrollTop() > $('.section-a').position.top ) {
$('.menu-items').removeClass('selected');
$('.menu-a').addClass('selected');
}
if ( $('body').scrollTop() > $('.section-b').position.top ) {
$('.menu-items').removeClass('selected');
$('.menu-b').addClass('selected');
}
if ( $('body').scrollTop() > $('.section-c').position.top ) {
$('.menu-items').removeClass('selected');
$('.menu-c').addClass('selected');
}
$.getJSON('https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&prop=extracts&exlimit=max&explaintext&exintro&exsentences=1&gsrsearch=suits&callback=?',function(json){
json = json.filter(function(val) {
return (val.index !== 1);
});
$(".message").html(JSON.stringify(json));
});
cesarrodas sends brownie points to @dickfink :sparkles: :thumbsup: :sparkles:
:star: 169 | @dickfink | http://www.freecodecamp.com/dickfink
$.getJSON('https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&prop=extracts&exlimit=max&explaintext&exintro&exsentences=1&gsrsearch=suits&callback=?',function(json){
json = json.filter(function(val) {
return (val.index !== 1);
});
$(".message").html(JSON.stringify(json));
});
victoriasimonetti sends brownie points to @dickfink :sparkles: :thumbsup: :sparkles:
:star: 170 | @dickfink | http://www.freecodecamp.com/dickfink
eg if you had a page with a bunch of “li” elements:
$( "li" )
.filter(function( index ) {
return index % 3 === 2;
})
.css( "background-color", "red" );
would cause third and sixth list items to be highlighted.
Hi i need help in the Weather app zipline
I dont get a response from the openweather api, if i put the urrl in the browser searchbar it loads but when i call it with the ajax jquery function i get nothing.
Here is my code:
$(document).ready(function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
var apiUrl= "api.openweathermap.org/data/2.5/weather?lat="+ position.coords.latitude + "&lon=" + position.coords.longitude + "&units=metric&APPID=388b9dfad805b961ba54355aedb86991"
$.ajax({
url:apiUrl,
success: function(weather){
console.log(weather);
},
})
});
}else {
$('#location-header').html('Geolocation is not available')
};
});
Thanks
Here is the pen link: http://codepen.io/SpiralOut17/pen/XXQmxM?editors=0011
@SpiralOut17 I dont get any longtitude nor an output in the div with the class "weather".This is my code:`function printweather(pos) {
var lon = pos.coords.longtitude;
var lat = pos.coords.latitude;
var url = "//api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&APPID=6ffb926f18657b3913623a729923200f";
$.getJSON(url, function(data) {
$(".weather").html(data);
});
}
$(document).ready(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(printweather);
}
});`
function printweather(pos) {
var lon = pos.coords.longtitude;
var lat = pos.coords.latitude;
var url = "//api.openweathermap.org/data/2.5/weather?lat="; + lat + "&lon=" + lon + "&units=metric&APPID=6ffb926f18657b3913623a729923200f";
$.getJSON(url, function(data) {
$(".weather").html(data);
});
}
$(document).ready(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(printweather);
}
});
ldiek- sends brownie points to @spiralout17 :sparkles: :thumbsup: :sparkles:
:star: 279 | @spiralout17 | http://www.freecodecamp.com/spiralout17
hey guys can someone please point me in the direction to fix my quote button |
http://codepen.io/drewpiper/pen/BjbjOW/?editors=0110
looking at how to get rid of that blue border when i click it, thank you
.btn:focus {outline: none;}
cooperreck sends brownie points to @urobert and @aidenbuis :sparkles: :thumbsup: :sparkles:
:star: 593 | @urobert | http://www.freecodecamp.com/urobert
:star: 134 | @aidenbuis | http://www.freecodecamp.com/aidenbuis
shakib609 sends brownie points to @aidenbuis :sparkles: :thumbsup: :sparkles:
:star: 135 | @aidenbuis | http://www.freecodecamp.com/aidenbuis
wyattwade sends brownie points to @aidenbuis :sparkles: :thumbsup: :sparkles:
:star: 136 | @aidenbuis | http://www.freecodecamp.com/aidenbuis
wyattwade sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 492 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
This an inline `<paste code here>
` code formatting with a single backtick(`) at start and end around the code
.
```js ⇦ Type 3 backticks and then press [shift + enter ⏎]
(type js or html or css)
<paste your code here>,
then press [shift + enter ⏎]
``` ⇦ Type 3 backticks, then press [enter ⏎]
See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants.type.trees.list[1]; // Change this line
This an inline `<paste code here>
` code formatting with a single backtick(`) at start and end around the code
.
```js ⇦ Type 3 backticks and then press [shift + enter ⏎]
(type js or html or css)
<paste your code here>,
then press [shift + enter ⏎]
``` ⇦ Type 3 backticks, then press [enter ⏎]
See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics
@cragsify // Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants.type.trees.list[1]; // Change this line
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants.type.trees.list[1]; // Change this line
wyattwade sends brownie points to @ronstarcool :sparkles: :thumbsup: :sparkles:
:star: 329 | @ronstarcool | http://www.freecodecamp.com/ronstarcool
sandipsubedi sends brownie points to @rune-jacobsen :sparkles: :thumbsup: :sparkles:
:star: 288 | @rune-jacobsen | http://www.freecodecamp.com/rune-jacobsen
zera99 sends brownie points to @cragsify :sparkles: :thumbsup: :sparkles:
:star: 316 | @cragsify | http://www.freecodecamp.com/cragsify
myPlants[1]
then you are inside the 2nd element in the main array, then if you do [1], you will access the 2nd, 2nd element
myPlants[1][1]
wyattwade sends brownie points to @ronstarcool :sparkles: :thumbsup: :sparkles:
:warning: wyattwade already gave ronstarcool points
hajeansonne sends brownie points to @cragsify :sparkles: :thumbsup: :sparkles:
:star: 317 | @cragsify | http://www.freecodecamp.com/cragsify
var secondTree = myPlants[1].list[1];
divaweb sends brownie points to @caleb272 :sparkles: :thumbsup: :sparkles:
:star: 132 | @caleb272 | http://www.freecodecamp.com/caleb272
zackluckyf sends brownie points to @cragsify :sparkles: :thumbsup: :sparkles:
:star: 318 | @cragsify | http://www.freecodecamp.com/cragsify
cooperreck sends brownie points to @cragsify :sparkles: :thumbsup: :sparkles:
:star: 320 | @cragsify | http://www.freecodecamp.com/cragsify
jackedwardlyons sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
cooperreck sends brownie points to @brettfelts :sparkles: :thumbsup: :sparkles:
:star: 360 | @brettfelts | http://www.freecodecamp.com/brettfelts
indexOf([11,33, 22,33], 33);
2
3 function indexOf(array, value) {
4 var result = -1;
5 var checkDuplicate = {};
6
7 for(var i = 0; i < array.length; i++) {
8 if(array[i] === value) {
9 checkDuplicate[array[i]] += 1;
10 if(checkDuplicate[array[i]] !== 1) {
11 result = i;
12 }
13 }
14 }
15
16 return result;
17
18 }
indexOf([11,33, 22,33], 33);
function indexOf(array, value) {
var result = -1;
var checkDuplicate = {};
for(var i = 0; i < array.length; i++) {
if(array[i] === value) {
checkDuplicate[array[i]] += 1;
if(checkDuplicate[array[i]] > 1) {
result = i;
}
}
}
return result;
}
<div class="navi">
<ul>
<li>About</li>
<li>Work</li>
<li>Team</li>
<li>Contact</li>
</ul>
</div>
.navi {
display: inline;
tex-align: center;
}
:bulb: to format code use backticks! ``` more info
.navi *{ display: inline; }
declanpaz sends brownie points to @gxenos :sparkles: :thumbsup: :sparkles:
:star: 246 | @gxenos | http://www.freecodecamp.com/gxenos
var lat;
var long;
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
lat=position.coords.latitude;
long=position.coords.longitude;
});
}
$("#temperature").html(lat+" and " + long);
Why the fudge does the lat and lang variable not get assigned?
var lat=0;
var long=0;
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
lat=position.coords.latitude;
long=position.coords.longitude;
$("#temperature").html(lat+" and " + long);
});
}
If I have the above code, inside the function, then it works
divaweb sends brownie points to @disjfa :sparkles: :thumbsup: :sparkles:
:star: 83 | @disjfa | http://www.freecodecamp.com/disjfa
annaslab sends brownie points to @swoozeki :sparkles: :thumbsup: :sparkles:
:star: 289 | @swoozeki | http://www.freecodecamp.com/swoozeki
chumswap sends brownie points to @swoozeki :sparkles: :thumbsup: :sparkles:
:star: 290 | @swoozeki | http://www.freecodecamp.com/swoozeki