setInterval()
and Tom also mentioned it above. It's not going to just run automatically - you would only have to have it test every minute or so, I would imagine?
var thisIs = "lunch";
if(hours >= starthour && minutes >= startminute && thisIs != "lunch") {
location.replace('lunch-4.html');
} else if (hours >= endhour && minutes >= endminute){
location.replace('breakfast-4.html')
}
display: none
in the appropriate way to get it to show what you want.
restrepomich sends brownie points to @khaduch and @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 907 | @mot01 |http://www.freecodecamp.org/mot01
:star2: 3508 | @khaduch |http://www.freecodecamp.org/khaduch
@moT01 - if you look at this code:
var thisIs = "lunch";
if(hours >= starthour && minutes >= startminute && thisIs != "lunch") {
location.replace('lunch-4.html');
} else if (hours >= endhour && minutes >= endminute){
location.replace('breakfast-4.html')
}
without the extra test for thisIs != "lunch"
, and it was the time that passed the test condition for lunch, it would navigate to the page again, via location.replace
. So it would run the same check again, navigate to the page again, and again, and again. So if you put some conditional check for which page you are on, you won't go to a page that you've already navigated to. A similar check has to be added for "breakfast", or else it will happen there.
:bulb: to format code use backticks! ``` more info
junipberry sends brownie points to @ev3rlord :sparkles: :thumbsup: :sparkles:
:cookie: 13 | @ev3rlord |http://www.freecodecamp.org/ev3rlord
junipberry sends brownie points to @asjas :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @asjas |http://www.freecodecamp.org/asjas
upload files
button - top right sort of - near the green button
junipberry sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 908 | @mot01 |http://www.freecodecamp.org/mot01
primuscovenant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2063 | @heroiczero |http://www.freecodecamp.org/heroiczero
Hey guys, I'm trying to create a series of images separated by arrows. Something like this:
Except instead of orange bubbles of text I'd like images. Is there a JS library that can help with this? Thanks.
var myStr= "\rFirstLine\n\\SecondLine\\\nThirdLine";
FirstLine
\SecondLine\
ThirdLine
.slice()
and .substr()
and .substring()
are basically the same?
substring
takes the start and the end as parameters, substr
start and length. slice
and substring
are pretty much the same (a few differences here), but slice
also works for arrays.'Hello World'.substr(2, 3); // llo
'Hello World'.substring(2, 3); // l
'Hello World'.slice(2, 3); // l
var str = 'hello World';
var start = 1;
var length = 2;
str.substr(start, length) === str.substring(start, start + length) && str.substr(start, length) === str.slice(start, start + length); // true
$(document).ready(function() {
var weapon
var gameStarted = false
// if a have choosen a weapon, I can no longer switch it, and I can start the game
if (!gameStarted){chooseWeapon(startGame)}
function startGame() {
$('.board .squares').on('click', function() {
$(this).children('.X0').html(weapon)
})
}
function chooseWeapon(callback) {
gameStarted = true
$('.weapons .squares').on('click', function() {
weapon = $(this).children('.X0').html()
})
callback()
}
})
radumatees sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8693 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
$('.weapons .squares').on('click', function(){
var weapon = $(this).children('.X0').html()
$('.weapons').hide()
startGame(weapon)
})
function startGame(weapon) {
$('.board .squares').on('click', function() {
$(this).children('.X0').html(weapon)
})
}
.shift()
right?
function chunkArrayInGroups(arr, size) {
// Break it up.
var a = arr.slice(0, size);
var b = [];
for (var x=1; x<arr.length/size ;x++) {
b.push(arr.slice(size*x, size*x+size));
}
var final=b.unshift(a);
return final;
}
chunkArrayInGroups(["a", "b", "c", "d", "e", "f", "g", "h"], 2);
quantomistro3178 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8695 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
junipberry sends brownie points to @asjas :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @asjas |http://www.freecodecamp.org/asjas
hensn5250 sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 444 | @tiagocorreiaalmeida |http://www.freecodecamp.org/tiagocorreiaalmeida
https://raw.githubusercontent.com/junipberry/vids/master/RainierFlowers.mp4
but it seems to not like playing it. I am using it in this codepen but it's not playing. Seems github is a bad idea. I'll suggest then using Vimeo or Youtube to host the video. They are the two best known video hosting platforms
filter
on firstParameter
but storing it in result
tkzs sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @kbaig |http://www.freecodecamp.org/kbaig
result
with firstParameter
in result = firstParameter.filter....
in your loop and return firstParameter
function destroyer(arr) {
// Remove all the values
return arguments.length === 1 ?
arr :
destroyer(arr.filter(n => n !== arguments[1]), ...Array.apply(null, arguments).slice(2));
}
junipberry sends brownie points to @asjas and @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @asjas |http://www.freecodecamp.org/asjas
:cookie: 427 | @kbaig |http://www.freecodecamp.org/kbaig
col
sizes?
Hey guys!
Someone could give an honest opinion on my personal portfolio project? (2nd challenge on freecodecamp)
https://codepen.io/sarkioja/full/NwvNpR
Thanks in advance
sarkioja sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @kbaig |http://www.freecodecamp.org/kbaig
<style>
body {
background-color: black;
font-family: Monospace;
color: green;
}
.pink-text {
color: pink;}
.blue-text {
color: blue;}
</style>
<h1 class="pink-text" "blue-text">Hello World!</h1>
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8696 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
var obj = {}
undefined
obj.t
undefined
obj.t = !obj.t
true
niloy513 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8697 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
krisb1220 sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 909 | @mot01 |http://www.freecodecamp.org/mot01
name: [ ]
business: [ ]