1/4
and it gave me 0.3
which is clearly wrong. So I'd say there's probably something wrong with your calculator
danjp2016 sends brownie points to @chrisbrownie55 :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @chrisbrownie55 |http://www.freecodecamp.org/chrisbrownie55
.toFixed
at all
danjp2016 sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 944 | @mot01 |http://www.freecodecamp.org/mot01
arr[3]; // equals [[10,11,12], 13, 14]
- because that is the element in arr
at index 3
. Then you continue from there with the breakdown. arr[3][0]
gives your the first element in that line - that is the sub-array [10, 11, 12]
, and adding another index arr[3][0][1]
gives you the second element in the [10,11,12]
, which is 11
.
kalzimonium sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3630 | @khaduch |http://www.freecodecamp.org/khaduch
kalzimonium sends brownie points to @danjp2016 :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @danjp2016 |http://www.freecodecamp.org/danjp2016
$addTask.on('click',function(){
$(this).after('<form id="newItem"><input type="text"> <input type="submit"></form>');
$(this).hide();
});
$('#newItem').on('submit', function(e){
e.preventDefault();
$(this).after('<li class="entry">newEntry</li>');
$(this).remove();
});
#newItem
hillsie sends brownie points to @danjp2016 :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @danjp2016 |http://www.freecodecamp.org/danjp2016
$(this).after('<form id="newItem"><input type="text"> <input type="submit"></form>');
$addTask.on('click',function(){
const $newItem = $('<form/>');
const $inputText = ${'<input/>', {type:'text'});
const $inputSubmit = $('<input/>', {type: 'submit'});
$newItem
.append($inputText)
.append($inputSubmit);
$newItem.on('submit', formSubmitCallback);
$(this).after($newItem);
$(this).hide();
});
function formSubmitCallback(e){
e.preventDefault();
const $li = $('<li/>', {text: 'newEntry'});
$(this).after($li);
$(this).remove();
}
Hello there, I’m having trouble in understanding how to use regex in order to trim spaces at the end and at the beginning of a string.
I’m referring to the regex lesson: https://beta.freecodecamp.org/en/challenges/regular-expressions/reuse-patterns-using-capture-groups
My solution would be something like:
let hello = " Hello, World! ";
let wsRegex = /^\s*(.*)\s*$/; // Change this line
let result = hello.replace(wsRegex, ''); // Change this line
But, of course, it’s not workin.
Could you be so kind to help me?
"$1"
Thanks, I’m starting to understand what the capturing group is used for :)
Now, I’m on this:
let hello = " Hello, World! ";
let wsRegex = /^\s*(.*)\s*$/; // Change this line
let result = hello.replace(wsRegex, '$1'); // Change this line
and I have as result: Hello, World!
with two spaces at the end.
It’s not considering the ending space and I’m wondering why
/^\s*(.*!)\s*$/
but it’s kinda a workaround… any better solution?
?
right after the *
inside of the capturing group
?
after a multiplier makes the multiplier non-greedy
i cant able to post the data
/.postman
its working properly .
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maxi</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<input type="text" id="search1" >
<input type="text" id="search2" >
<button class="btn-primary">click</button>
<div class="well"></div>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type : "POST",
url : "/api/ninjas",
data : {
name : $("#search1").val(),
rank : $("#search2").val()
},
success : function(data){
console.log(data.name);
},
error : function(err){
console.log('error' ,err);
}
});
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maxi</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<input type="text" id="search1" >
<input type="text" id="search2" >
<button class="btn-primary">click</button>
<div class="well"></div>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type : "POST",
url : "/api/ninjas",
data : {
name : $("#search1").val(),
rank : $("#search2").val()
},
success : function(data){
console.log(data.name);
},
error : function(err){
console.log('error' ,err);
}
});
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maxi</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<input id="search1" placeholder="enter playername">
<input id="search2" placeholder="enter playerscore">
<button class="btn-primary">click</button>
<div class="well"></div>
</body>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type : "POST",
dataType : "json",
url : "http://localhost:4000/api/maxi",
data :{
"player" : $("#search1").val(),
"score" : $("#search2").val()
},
success : function(data){
console.log(data);
},
error : function(err){
console.log('error' ,err);
}
});
});
});
</script>
</html>
id
)
Math.minMax()
function minMax () {
return [Math.min.apply(null,arguments),Math.max.apply(null,arguments)];
}
minMax(1,5,3,7); // [ 1, 7 ]
cjrutherford sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 472 | @gothamknight |http://www.freecodecamp.org/gothamknight
$.ajax({
type : "POST",
url : "http://localhost:4000/api/maxi",
JSON.stringify(data :{
player : $("#search1").val(),
score : $("#search2").val()
}),
dataType : "json",
success : function(data){
console.log(data);
},
error : function(err){
console.log('error' ,err);
}
});
Uncaught ReferenceError: require is not defined
"use strict";
const result = {
success: ["max-length", "no-amd", "prefer-arrow-functions"],
failure: ["no-var", "var-on-top", "linebreak"],
skipped: ["id-blacklist", "no-dup-keys"]
};
// change code below this line
const resultDisplayArray = `<li class="text-warning">${result.failure[0]}</li>
<li class="text-warning">${result.failure[1]}</li>
<li class="text-warning">${result.failure[2]}</li>`
// change code above this line
console.log(resultDisplayArray);
/**
* should look like this
* <li class="text-warning">no-var</li>
* <li class="text-warning">var-on-top</li>
* <li class="text-warning">linebreak</li>
**/
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maxi</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<input id="search1" placeholder="enter playername">
<input id="search2" placeholder="enter playerscore">
<button class="btn-primary">click</button>
<div class="well"></div>
</body>
<script>
$(document).ready(function(){
$(".btn-primary").click(function(){
console.log("click");
var obj = {
player : $("#search1").val(),
score : $("#search2").val()
};
$.ajax({
type : "POST",
url : "http://localhost:4000/api/maxi",
data : obj ,
success : function(data){
console.log(data);
},
error : function(err){
console.log('error' ,err);
},
dataType : "json"
});
});
});
</script>
</html>
```
function uniteUnique(arr) {
var argArr = Array.from(arguments);
var newArr = argArr.reduce(function(x){
return newArr.indexOf(x) == -1;
}, []);
return newArr;
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
bootstrap 4 captions are now like this :
https://v4-alpha.getbootstrap.com/content/figures/
so I think your code chould be
<div class="figure">
<img class="figure-img img-fluid" src="https://media-exp2.licdn.com/mpr/mpr/AAEAAQAAAAAAAAg3AAAAJDkyYmM1ZTQ5LTI5YmQtNGUwZS1iMjY3LTlhMDk0ZWQ2YzAwMw.jpg">
<figcaption class="figure-caption text-center">The Eiffel Tower at night.</figcaption>
</div>
and if you want the white background for the caption then add
.figure{
background-color:white;
}
to your css
@cyoung045 .thumbnail {
border: solid white;
}
.img-thumbnail {
border: none;
}
.caption {
background-color: white
}
function(acc,elem){...}
where acc will be the running value (accumulator that is an array here) and elem is the array element being iterated, and figure out what the next accumulator should be and return it.
mgrienauer sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4631 | @masd925 |http://www.freecodecamp.org/masd925
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maxi</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<input id="search1" placeholder="enter playername">
<input id="search2" placeholder="enter playerscore">
<button class="btn-primary">click</button>
<div class="well"></div>
</body>
<script>
$(document).ready(function(){
$(".btn-primary").click(function(){
console.log("click");
var obj = {
player : $("#search1").val(),
score : $("#search2").val()
};
$.ajax({
type : "POST",
url : "http://localhost:4000/api/maxi",
data : obj ,
success : function(data){
console.log(data);
},
error : function(err){
console.log('error' ,err);
},
dataType : "json"
});
});
});
</script>
</html>
Uncaught ReferenceError: require is not defined
function titleCase(str) {
var strWords = str.split(" "); // stores input of function
var strOutput = []; // stores output of function
var strTemp = []; // temporary array used to store letters of each word
for (i = 0; i < strWords.length; i++){
strWords[i] = strWords[i].toLowerCase(); // change each word of input to lowercase
}
for (j = 0; j < strWords.length; j++){
strTemp.push(strWords[j].split("")); // push the current word of input string to temp array as a split string
strTemp[0] = strTemp[0].toUpperCase(); // change the first letter (first array index) of current word to uppercase
strOutput.push(strTemp.join("")); // push modified word to output array
strTemp = []; // clear temporary array for next iteration
}
return strOutput.join(" "); // output string from joined array of modified words
}
titleCase("I'm a little tea pot");
This function is supposed to capitalize the first letter of each word of an input string. However, I get the error that toUpperCase() is not a function. Any ideas?
strTemp = strWords[j].split("")
davidbelmares sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8808 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm