background-size: cover
sabin20 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 495 | @longnt80 |http://www.freecodecamp.com/longnt80
function translatePigLatin(str) {
var vowelsArr = 'aeiou'; //way
//var constArr = 'BCDFGHJKLMNPQRSTVWXYZ'.toLowerCase(); //ay
var uno = [];
var dos = [];
str = str.split('');
if (vowelsArr.indexOf(str[0]) === -1) {
for (var i = 0; i < str.length; i++) {
if (vowelsArr.indexOf(str[i]) === -1) {
dos.push(str[i]);
} else if (vowelsArr.indexOf(str[i]) > -1) {
uno.push(str[i]);
uno = uno.join('');
dos = dos.join('');
return uno + dos;
}
}
} else {
return str.join('') + 'way';
}
}
//translatePigLatin("consonant");
//translatePigLatin("california"); //should return "aliforniacay".
//translatePigLatin("paragraphs"); //should return "aragraphspay".
translatePigLatin('glove'); //should return "oveglay".
//translatePigLatin("algorithm"); //should return "algorithmway".
//translatePigLatin("eight"); //should return "eightway".
float: right;
@gothamknight truthfully, I'd like to know in you guy's opinion what's the best way to accomplish center/center positioning for the "quote generator" div and getting that "-Author" to the right?
I know there are always multiple ways to do something but I'm trying to find the best way
flexbox
to vertically/horizontally center something
body
flex though
gothamknight sends brownie points to @bgarbs and @kirah1314 :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @bgarbs |http://www.freecodecamp.com/bgarbs
:cookie: 997 | @kirah1314 |http://www.freecodecamp.com/kirah1314
h-100 d-flex justify-content-center align-items-center
import React from 'react'
.toString()
on them to compare the strings. You might also want to look back at your solution to the Diff Two Arrays challenge.
taijones00 sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2373 | @skyc0der |http://www.freecodecamp.com/skyc0der
xs
, sm
, md
, etc... grid sizes are for
xs
and just use col-xs-12
xs
first and see if that's what you like
<div class = "col-xs-12 col-sm-10 col-md-10 col-sm-offset-1 col-md-offset-1 blue about">
sm
too
[ ]>
rgba
does, it make the color transparent.
.section2 {
line-height: 100%;
background-color: rgba(0, 0, 0, 0.5);
color: #eee;
text-align: center;
position: absolute;
width: 100%;
top: 40%;
}
taijones00 sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2374 | @skyc0der |http://www.freecodecamp.com/skyc0der
taijones00 sends brownie points to @1532j0004kg :sparkles: :thumbsup: :sparkles:
:cookie: 238 | @1532j0004kg |http://www.freecodecamp.com/1532j0004kg
can any body help to solve the 'Chunky Monkey' algorithm problem?
here is my code:
function chunkArrayInGroups(arr, size) {
// Break it up.
var myArr = [];
var a = arr.length / size;
for(var i = 0; i < a; i++){
myArr = arr.slice(arr[a], size);
console.log(myArr);
}
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
I'm sure i do something idiotic logic. can you tell me where am i doing wrong , plz? and how can i get those outputs
Array.slice()
console.log
is basically a diagnostic tool, it will not return any useful values to the caller of the function.
/* -----------------
* Return ajax data
* ----------------- */
function appendYouTubeData(data, query) {
// append results & HTML wrapper
$(innerWrapper).append(
'<h2 class="text-center">Results for: ' + query + '</h2>' +
'<div id="results" class="row flex-wrap video-row w-95 m-auto"></div>'
);
// Iterate over each video & append HTML
appendEachVideo(data);
} /* ------ end appendYouTubeData() ------ */
/* ----------------
* Helper Functions
* ---------------- */
function appendEachVideo(videos) {
$.each(videos.items, function(i, item) {
var output = getOutput(item, item.id.videoId);
$('#results').append(output);
});
}
function appendEachVideo(videos, id) {
$.each(videos.items, function(i, item) {
var output = getOutput(item, id);
$('#results').append(output);
});
}
id
in another section of my code, it returns undefined
76
@korzo
186
should be refactored
function appendEachVideo(videos) {
$.each(videos.items, function(i, item) {
var output = getOutput(item, item.id.videoId); //
$('#results').append(output);
});
}
function appendEachVideo(videos, videoId) {
$.each(videos.items, function(i, item) {
var output = getOutput(item, videoId);
$('#results').append(output);
});
}
function search() {
// Clear Results
$(innerWrapper, resultsWrapper, buttonsWrapper).html('');
// Get Form Input
q = $('#query').val();
// Run Get request on API
$.get(
"https://www.googleapis.com/youtube/v3/search", {
part: 'snippet, id',
q: q,
channelId: 'UCLhwHoIKtoWBccOFPDmEFpQ',
maxResults: 6,
type: 'video',
key: 'AIzaSyDKJYxyWUDZhykA8DUVOorUbmC7J7QAAUg' },
function(data) {
appendYouTubeData(data, q, item.id.videoId);
speedUpYouTubeLoad(); // add thumbnail instead of full iframe load.
}
);
} /* ------ end search() ------ */
/* -----------------
* Return ajax data
* ----------------- */
function appendYouTubeData(data, query, videoId) {
// append results & HTML wrapper
$(innerWrapper).append(
'<h2 class="text-center">Results for: ' + query + '</h2>' +
'<div id="results" class="row flex-wrap video-row w-95 m-auto"></div>'
);
// Iterate over each video & append HTML
appendEachVideo(data, videoId);
} /* ------ end appendYouTubeData() ------ */
/* ----------------
* Helper Functions
* ---------------- */
function appendEachVideo(videos, videoId) {
$.each(videos.items, function(i, item) {
var output = getOutput(item, videoId);
$('#results').append(output);
});
}
appendYouTubeData(data, q, item.id.videoId);
item.id.videoId
as a variable or something to pass it in
videoId
in the appendEachVideo
function
197
68
appendYouTubeData(data, q, function(item) {return item.id.videoId});
function search() {
// Clear Results
$(innerWrapper, resultsWrapper, buttonsWrapper).html('');
// Get Form Input
q = $('#query').val();
// Run Get request on API
$.get(
"https://www.googleapis.com/youtube/v3/search", {
part: 'snippet, id',
q: q,
channelId: 'UCLhwHoIKtoWBccOFPDmEFpQ',
maxResults: 6,
type: 'video',
key: 'AIzaSyDKJYxyWUDZhykA8DUVOorUbmC7J7QAAUg' },
function(data) {
appendYouTubeData(data, q,
$.each(data.items, function(i, item) {
var output = getOutput(item, item.id.videoId);
$('#results').append(output);
})
);
speedUpYouTubeLoad(); // add thumbnail instead of full iframe load.
}
);
callback is not a function
@korzo
appendYouTubeData(data, q, function(item) {return item.id.videoId});
var output = getOutput(item, videoId(item));
callback
like this >>function appendYouTubeData(data, query, callback) {
function search() {
// Clear Results
$(innerWrapper, resultsWrapper, buttonsWrapper).html('');
// Get Form Input
q = $('#query').val();
// Run Get request on API
$.get(
"https://www.googleapis.com/youtube/v3/search", {
part: 'snippet, id',
q: q,
channelId: 'UCLhwHoIKtoWBccOFPDmEFpQ',
maxResults: 6,
type: 'video',
key: 'AIzaSyDKJYxyWUDZhykA8DUVOorUbmC7J7QAAUg' },
function(data) {
appendYouTubeData(data, q, function() {
$.each(data.items, function(i, item) {
var output = getOutput(item, item.id.videoId);
$('#results').append(output);
});
});
speedUpYouTubeLoad(); // add thumbnail instead of full iframe load.
}
);
} /* ------ end search() ------ */
/* -----------------
* Return ajax data
* ----------------- */
function appendYouTubeData(data, query, callback) {
// append results & HTML wrapper
$(innerWrapper).append(
'<h2 class="text-center">Results for: ' + query + '</h2>' +
'<div id="results" class="row flex-wrap video-row w-95 m-auto"></div>'
);
callback();
// Iterate over each video & append HTML
// appendEachVideo(data);
appendNextButton(data);
} /* ------ end fTubeData() ------ */
function search() {
// Clear Results
$(innerWrapper, resultsWrapper, buttonsWrapper).html('');
// Get Form Input
q = $('#query').val();
// Run Get request on API
$.get(
"https://www.googleapis.com/youtube/v3/search", {
part: 'snippet, id',
q: q,
channelId: 'UCLhwHoIKtoWBccOFPDmEFpQ',
maxResults: 6,
type: 'video',
key: 'AIzaSyDKJYxyWUDZhykA8DUVOorUbmC7J7QAAUg' },
function(data) {
appendYouTubeData(data, q, function(item) {return item.id.videoId});
speedUpYouTubeLoad(); // add thumbnail instead of full iframe load.
}
);
} /* ------ end search() ------ */
/* -----------------
* Return ajax data
* ----------------- */
function appendYouTubeData(data, query, videoId) {
// append results & HTML wrapper
$(innerWrapper).append(
'<h2 class="text-center">Results for: ' + query + '</h2>' +
'<div id="results" class="row flex-wrap video-row w-95 m-auto"></div>'
);
// Iterate over each video & append HTML
appendEachVideo(data, videoId);
} /* ------ end appendYouTubeData() ------ */
/* ----------------
* Helper Functions
* ---------------- */
function appendEachVideo(videos, videoId) {
$.each(videos.items, function(i, item) {
var output = getOutput(item, videoId(item));
$('#results').append(output);
});
}
jackedwardlyons sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 368 | @korzo |http://www.freecodecamp.com/korzo
hello masters!! need help. i have a problem on algorithm entitled pig latin.
how can i stop the loop when it hit another consonant?? i tried return and i cant make it work.heres my code:
function translatePigLatin(str) {
var vowelsArr = 'aeiou'; //way
//var constArr = 'BCDFGHJKLMNPQRSTVWXYZ'.toLowerCase(); //ay
var uno = [];
var dos = [];
str = str.split('');
if (vowelsArr.indexOf(str[0]) === -1) {
for (var i = 0; i < str.length; i++) {
if (vowelsArr.indexOf(str[i]) === -1) {
dos.push(str[i]);
} else if (vowelsArr.indexOf(str[i]) !== -1) {
uno.push(str[i]);
uno = uno.join('');
dos = dos.join('');
return uno + dos + 'ay';
}
}
} else {
return str.join('') + 'way';
}
}
//translatePigLatin("consonant");
//translatePigLatin("california"); //should return "aliforniacay".
//translatePigLatin("paragraphs"); //should return "aragraphspay".
translatePigLatin('glove'); //should return "oveglay".
do i need to put a counter so i can count how many characters to remove? im not gonna use substr im just going to use splice.
a2-zubair sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3198 | @khaduch |http://www.freecodecamp.com/khaduch
var apiUrl = "your google search API url";
var searches = ["sports in California", "sports in New York"];
var requests = searches.map(function(search) {
return fetch(apiUrl + search).then(function(response) {
return response.json();
});
});
Promise.all(requests)
.then(function(data) {
console.log(data); // this has JSON responses for each item in the searches array
})
.catch(function(err) {
console.error(err);
});
taijones00 sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @gothamknight |http://www.freecodecamp.com/gothamknight
overflow: auto;
would be more elegant
json[randomNumber]
)