:bulb: to format code use backticks! ``` more info
<form target='_blank' action='https://twitter.com/intent/tweet?text=bla'><button id='tweet-btn' class='btn btn-primary'>Tweet the quote</button></form>
https://twitter.com/intent/tweet?text=helloWorld
class="btn btn-primary"
berndbausch sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 192 | @skycoder01 |http://www.freecodecamp.com/skycoder01
var data = 'hello';
function sayHello(data) {
console.log(data); // this outputs 'hello'
}
$.ajax
is going to the URL you give it and assigning the data at the URL to data
instead of you creating your own variable
function(data) {}
jumpship91 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1485 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
cj2340392 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1486 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Hi everyone: I'm having trouble with my first HTML project (creating a tribute page). http://codepen.io/ThurstianTsui/pen/EZGjVx
I have two main issues right now:
Can anyone shed some light on what I should be doing differently?
iriquoi sends brownie points to @athabasco :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @athabasco |http://www.freecodecamp.com/athabasco
<div class="container-fluid row mainsection">
<div class="col-lg-6" id="sec1">
<h1 class="text-center" id="cololoo">South Africa…It’s here!</h1>
</div>
<div class="col-lg-6" id="sec2">
</div>
</div>
@AshanMohammed like this <div class="container-fluid row mainsection">
<div class="col-lg-6" id="sec1">
<h1 style="color:red" class="text-center" id="cololoo">South Africa…It’s here!</h1>
</div>
<div class="col-lg-6" id="sec2">
</div>
</div>
HELP WITH D3 - anyone here could go through my code and explain to me what have I done wrong that my circles are not fixed to the x axis?
@mones-cse There are 2 behaviors:
scrolling left and right - I expect the green circles to stay where they we're originally rendered for example if one of the circles was rendered on 9:30 am it should stay there on the x Axis even when moving right or left.
zoom - when zooming in and out - I expect the 9:30 green circle to re-render itself back to 9:30 on the new resolution of the x Axis
Hello, friends! I am writing code for Random Quote Machine. I have problem with quotes that exseed 140 characters. Can you give me an advice how to get only short quotes?
function generateFaces(){
var x=0, y=0;
var numberOfFaces =3;
var theLeftSide=document.getElementById("leftSide");
var theRightSide=document.getElementById("rightSide");
numberOfFaces = numberOfFaces + Math.floor(Math.random()*6);
for(var i=numberOfFaces;i>0;i--){
var x=Math.floor(Math.random()*400);
var y=Math.floor(Math.random()*400);
var img_tag=document.createElement("img");
img_tag.src = "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png";
img_tag.style.left=x +'px'; //left 0>>400px
img_tag.style.top=y +'px'; //right 0>>400px
var leftSideImages=theLeftSide.appendChild(img_tag);
/*problems start here*/
var xx=document.createElement('div');
xx=leftSideImages.cloneNode(true);
theRightSide.appendChild(xx);
x=x+10; y=y+10;
}}
zhann1982 sends brownie points to @bd1887 and @alienavatar :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for alienavatar
:cookie: 341 | @bd1887 |http://www.freecodecamp.com/bd1887
url
variable hence it gets so long.
url = url + users[i];
you can do var tmpURL = url + users[i];
and use tmpURL
with the ajax call
radekjohn sends brownie points to @oppiniated :sparkles: :thumbsup: :sparkles:
:cookie: 569 | @oppiniated |http://www.freecodecamp.com/oppiniated
randomCry() {
var self = this
for (let i = 0; i < this.state.randomSound.length; i++) {
var randomPokemon = this.state.randomSound[i]
var audio = self.state.audio
audio.src = randomPokemon
audio.play();
}
}
alejofcc sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
alejofcc sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1782 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
error:"forbidden"
msg:"unaccepted route: streams/ - see https://wind-bow.gomix.me/ for infos"
radekjohn sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 504 | @taltmann42 |http://www.freecodecamp.com/taltmann42
radekjohn sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1783 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
url
to the API, but url
is an just the urlPrep
plus an empty string (user
) at that point
user
in the for-loop but that doesn't change the url
/streams
not, 8 different requests with the user in the url
user
inside the callback for example. The loop itself has finished so in the variable user
is only the last entry
getStreamData(user)
.user
parameter and makes the ajax call. You simply call this function in your for-loop. That works because in that case each instance of user
is in its own context
radekjohn sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:warning: radekjohn already gave taltmann42 points
<div class = "jumbotron text-center>"
onlick
would do anything ;)
>
is still in the class-string
math
doesn't exist, it should be Math
onlick
krimsonmedic sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 505 | @taltmann42 |http://www.freecodecamp.com/taltmann42
quoteDisplay
, but the button is also in that div, so it gets overwritten
.vertical-align {
display: flex;
align-items: center;
}
krimsonmedic sends brownie points to @lorrie01 :sparkles: :thumbsup: :sparkles:
:cookie: 340 | @lorrie01 |http://www.freecodecamp.com/lorrie01
Hi! I can't figure out why my code doesn't work. I wonder if any of you could help me. I'm trying to complete the "local weather" project. When I run the code I get the following error:
""jQuery.Deferred exception: navigation is not defined" "@pen.js:13:5
g/</j@https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29946
g/</k<@https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262
" undefined"
I'm only starting this project. Here's my pen:
drbathound sends brownie points to @pharaohlxvi :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @pharaohlxvi |http://www.freecodecamp.com/pharaohlxvi
var searchTerm = 'albert einstein';
var searchUrl = "//en.wikipedia.org/w/api.php?action=opensearch&search="+searchTerm+"&limit=100&format=json&callback=?";
$.getJSON(searchUrl, function(json) {
$("#div1").html(JSON.stringify(json));
});
I would like this: http://codepen.io/firstinten/full/JExeQp/
to emulate this: https://coolors.co/77878b-b4b8c5-85969f-1b2223-dce8e4
where my div elements fit the page. Any guidance appreciated!
runnerbill75 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1487 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
@singleincome Hi. Something like this?
.container {
padding: 0;
height: 100vh;
width: 100%;
display: table;
table-layout:fixed;
}
.div1 { //Style the other divs with the same width and padding
border-style: solid;
border-color: black;
position: relative;
width: 20%;
padding: 0;
background-color: #FFF;
display: table-cell;
overflow: hidden;
}
You can also remove the borders to make it more like the link you posted
navigation
is undefined
//HTML
<div class = "container">
<div class = "col" id ="div1"> #F1FFFA</div>
<div class="col" id ="div2">#1B2223</div>
<div class="col" id="div3">#B4B8C5</div>
<div class="col" id = "div4">#85969F</div>
<div class="col" id="div5"> #77878B</div>
</div>
.container {
padding: 0;
height: 100vh;
width: 100%;
display: table;
table-layout:fixed;
font-family: segoe;
font-size: 20px;
color: black;
}
.col {
border-style: none;
position: relative;
width: 20%;
padding: 0;
display: table-cell;
overflow: hidden;
}
#div1 {
background-color: #FFF;
}
#div2 {
background-color: #1B2223;
}
#div3 {
background-color: #B4B8C5;
}
#div4 {
background-color: #85969F;
}
#div5 {
background-color: #77878B;
}
navigator.geolocation
and then use navigation
pharaohlxvi sends brownie points to @oppiniated :sparkles: :thumbsup: :sparkles:
:cookie: 574 | @oppiniated |http://www.freecodecamp.com/oppiniated
pharaohlxvi sends brownie points to @fortmaximus :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @fortmaximus |http://www.freecodecamp.com/fortmaximus
singleincome sends brownie points to @bd1887 :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @bd1887 |http://www.freecodecamp.com/bd1887
@singleincome You forgot to add a "." before ".container"
.container {
padding: 0;
height: 100vh;
width: 100%;
display: table;
table-layout:fixed;
}
It's the little things :-/
yogesh-captain sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 195 | @skycoder01 |http://www.freecodecamp.com/skycoder01
runnerbill75 sends brownie points to @achudoz :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @achudoz |http://www.freecodecamp.com/achudoz
@runnerbill75 you have to change the columns so their combined width is no more than 12.
e.g .
```
<div class="row">
<div class ="col-md-8">
</div>
<div class="col-md-4">
</div>
<h2>Tomahawk Digital Designs</h2>
<div id="button-wrapper" class="container container-fluid">
<button><i class="fa fa-twitter fa-fw" aria-hidden="true"></i> Twitter</a></button>
<button><i class="fa fa-github fa-fw" aria-hidden="true"></i> Github</a></button>
<button><i class="fa fa-linkedin fa-fw" aria-hidden="true"></i> LinkedIn</a></button>
<button><i class="fa fa-free-code-camp fa-fw" aria-hidden="true"></i> Free Code Camp</a></button>
</div>
#button-wrapper {
text-align: center;
background-color: yellow;
position: absolute;
top: 45%;
}
text-center
class and for images, use the center-block
class.
i did it
// Example
var changed = 0;
function change(num) {
return (num + 5) / 3;
}
changed = change(10);
// Setup
var processed = 2;
function processArg(num) {
processed=processArg;
return (num + 3) / 5;
}
// Only change code below this line
function add(x,y){
return x+y;
}
//result is 4
add(2,2);
answer = add(2, 2);
$("#quoteBtn").click(function() {
$('#quoteText').html(parsed_data.quote);
$('#authorText').html("- " + parsed_data.author);
});
parsed_data
is in scope
var parsed_data = $.parseJSON(data); //parse the data so its usable
$("#quoteBtn").click(function() {
$('#quoteText').html(parsed_data.quote);
$('#authorText').html("- " + parsed_data.author);
});
console.log(parsed_data.quote)
clearBoard()
which seems to set everything to the original state upon loading the game (currently when the spotsTaken are 9), but after I call it, nothing is able to be drawn on the board anymore.
while ($(randomCell).prop("hasSign") !== undefined) {
hasSign
property to undefined.
centered
to your td element: <td class="active centered">
.centered {
text-align: center;
}
undefined
if it is, do nothing, otherwise set it to that value
true
.
if(prop2 === undefined) {
//get property
}else{
//set property
}
false
instead of undefined
undefined
check to === true
and set the values when cleraing the board to false
.
if ( value !== undefined ) {
freakishlancer sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 509 | @taltmann42 |http://www.freecodecamp.com/taltmann42
When you don't use a table, you can make it as simple as:
<div class="user-row">
<span class="status-text">Some twitch user's status goes here</span>
<img src="https://placehold.it/300">
</div>
With this CSS:
img {
vertical-align: middle;
border-radius: 50%;
max-width: 100px;
}
eweiss17 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1488 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
runnerbill75 sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1489 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
.offline
instead of #offline
and you can't call a subfunction of another function, so you'll need to move showOnline() outside of your document.ready function.
radekjohn sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1490 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
I've been coding it as such:
<label><input type="button" class="btn" name="like-button"> Like</label>
return set
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
var x =text.split("");
for(var i =0; i<x.length; i++){
var mySet = new Set();
if(!mySet.has(x[i])) {
set =mySet.add(x[i])
}
console.log(set)
}
}
isIsogram('olkskdjf')
S
then this is a Set class -> https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set
set
to which you assigned the returnvalue of add
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add where there is no
var mySet = new Set();
if(!mySet.has(x[i])) {
mySet.add(x[i]);
}
console.log(mySet);
var mySet = new Set();
if(!mySet.has(x[i])) {
mySet.add(x[i])
}
console.log(mySet)
}
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
var x =text.split("");
for(var i =0; i<x.length; i++){
var mySet = new Set();
if(!mySet.has(x[i])) {
mySet.add(x[i])
}
console.log(mySet)
}
}
isIsogram('olkskdjf')
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
var x =text.split("");
var mySet = new Set();
for(var i =0; i<x.length; i++){
if(!mySet.has(x[i])) {
mySet.add(x[i])
}
console.log(mySet)
}
}
isIsogram('olkskdjf')
An isogram is a word that has no repeating letters, consecutive or non-consecutive.
Write and test a function that determines whether a string is an isogram.
Notes:
* Assume your input is only letters.
* Assume the empty string is an isogram.
* Ignore case.
* Follow the pseudocode exactly!
Starter Code :
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
}
@SkyCoder01
<form action="/like-cat-photo">
<label><input type="button" class="btn" name="like-button"> Like</label>
</form>
for
loop
var mySet = new Set();
threat-hunter sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 198 | @skycoder01 |http://www.freecodecamp.com/skycoder01
thurstiantsui sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1491 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
text
instead of x
new Set('olkskdjf'.split(""))
return new Set(text);
in the function body would already be enough :D
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
var mySet = new Set();
for(var i =0; i<text.length; i++){
if(!mySet.has(text[i])) {
mySet.add(text[i])
}
}
return mySet
console.log(mySet.length)
}
isIsogram('olksdddjf')
return new Set(text).size === text.length;
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
var mySet = new Set();
for(var i =0; i<text.length; i++){
if(!mySet.has(text[i])) {
mySet.add(text[i])
if(mySet.length === text.length){
return text + "is an isogram"
}
}else{
return "not an isogram"
}
}
}
isIsogram('olksdjf')
function isIsogram(text) {
// add each char to a set
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// note: a set drops dup values
// thus, to see if all the chars were unique,
// check length of text and the size of the set
var mySet = new Set();
for(var i =0; i<text.length; i++){
if(!mySet.has(text[i])) {
mySet.add(text[i])
}
}
if(mySet.length === text.length){
return text + "is an isogram"
}
}
isIsogram('olksdjf')
undefined
.length
is no property of mySet
which ends in undefined
. Use .size
for the set instead
johnnunns sends brownie points to @alpox and @taltmann42 and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 512 | @taltmann42 |http://www.freecodecamp.com/taltmann42
:star2: 2694 | @moigithub |http://www.freecodecamp.com/moigithub
:cookie: 769 | @alpox |http://www.freecodecamp.com/alpox
indexOf
and lastIndexOf
a="";
a.
it opens a list of methods/properties available for strings (cuz a="" on this example)const boardData = {
"cellTypes": {
0: "corner", 1: "edge", 2: "corner",
3: "edge", 4: "center", 5: "edge",
6: "corner", 7: "edge", 8: "corner"
},
"winCombos": {
0: ["corner", "edge", "corner"],
1: ["corner", "center", "corner"],
2: ["edge", "center", "edge"]
}
};
Im trying to make a twitter button that opens with some text but its always filled with the link of my codepen :(
html:
<a class="tweet" href="https://twitter.com/share" data-text="" target="_blank"><button class="btn btn-primary">Tweet this!</button></a>
jquery:
$('.tweet').attr('data-text', "Hi");
feelsbadman
charlesdarkwind sends brownie points to @moi238 :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @moi238 |http://www.freecodecamp.com/moi238
function findMaxRepeatCountInWord(word) {
return word.split("")// Break up individual words into individual letters.
.reduce(function(result, letter){
var regexp = new RegExp(letter, 'g')
result[letter] = word.match(regexp).length
return result;
}, [])
return word;
// Count the instances of each letter
// Iterate all the counts and find the highest
// Return this word's max repeat count
}
this.setGear = function () {
gear++;
};
this.getGear = function () {
return gear;
};
my whole code ```
var Bike = function() {
// Only change code below this line.
var gear;
this.setGear = function () {
gear++;
};
this.getGear = function () {
return gear;
};
};
var myBike = new Bike();
```
var Bike = function() {
// Only change code below this line.
var gear = 0;
this.setGear = function (change) {
gear += change;
};
this.getGear = function () {
return gear;
};
};
var myBike = new Bike();
Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.
ilonchik sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 517 | @taltmann42 |http://www.freecodecamp.com/taltmann42
33.3333%
and then use either float:left
on the boxes or display:flex; flex-wrap:wrap
on the container
var Bike = function() {
// Only change code below this line.
var gear = 0;
this.setGear = function (shift) {
gear += shift;
};
this.getGear = function () {
return gear;
};
};
var myBike = new Bike();
goingallthewayup sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 518 | @taltmann42 |http://www.freecodecamp.com/taltmann42
=
assigns the thing to the right of it to the thing to the left of it (a=5
assigns 5 to a). ==
and ===
check if the left value and the right value is the same. Difference is, that ==
doesn't check the type, so 5=="5"
is true, and 5==="5"
is false because one is of type number
and one of type string
goingallthewayup sends brownie points to @johnnunns :sparkles: :thumbsup: :sparkles:
:cookie: 183 | @johnnunns |http://www.freecodecamp.com/johnnunns
Can someone help me with this?
$.ajax({
type: "GET",
url: "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=Jimi_Hendrix&callback=?",
contentType: "application/json; charset=utf-8",
async: false,
dataType: "json",
success: function (pagina){
var trovato = pagina.query.pages;
console.log(pagina)
$.each(trovato, function(i,j){
$("#risultati").append("<li>" + trovato.pageid+ "</li>")
})
},
error: function (errorMessage) {
}
});
function findMaxRepeatCountInWord(word) {
var x = word.split("")// Break up individual words into individual letters.
.reduce(function(result, letter){
var regexp = new RegExp(letter, 'g')
result[letter]= word.match(regexp).length
return result;
}, {})
return x
// Count the instances of each letter
// Iterate all the counts and find the highest
// Return this word's max repeat count
}
var singleVal = array.reduce(function(previousVal, currentVal) {
return previousVal - currentVal;
}, 0);
var array = [5, 10, 20];
var singleVal = array.reduce(function(previousVal, currentVal) {
console.log('prev: ', previousVal);
console.log('curr: ', currentVal);
return previousVal - currentVal;
}, 0);
console.log(singleVal);
0
to see what happens:
:cookie: 199 | @skycoder01 |http://www.freecodecamp.com/skycoder01
goingallthewayup sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
initialValue
from these docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
initialValue
. The value to use as the first argument to the first call of the callback.
var singleVal = array.reduce(function(previousVal, currentVal) {
return previousVal - currentVal;
}, 0);
var singleVal = array.reduce((a,b) => {return a - b;}, 0);