@rrspence The length is optional.
var str = "Open sesame";
var lastFive = str.substr(-5); // esame
OR...only get the 3 characters after the fifth to last character:
var str = "Open sesame";
var lastFive = str.substr(-5, 3); // esa
confirmEnding("Open sesame", "same")
.prop()
$(hiddenFields).each(function(field_i, field) {
$(field).prop('id', function(p, value) {
return value.replace(/\[[0-9]+\]/g, '[' + list_i + ']');
})
$(field).prop('name', function(p, value) {
return value.replace(/\[[0-9]+\]/g, '[' + list_i + ']');
})
});
$(hiddenFields).each(function(field_i, field) {
const getValue = (p, value) => value.replace(/\[[0-9]+\]/g, "[" + list_i + "]");
$(field).attr({
"id": getValue(p, value),
"name": getValue(p, value)
});
});
jackedwardlyons sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2631 | @gulsvi |http://www.freecodecamp.org/gulsvi
rrspence sends brownie points to @gulsvi and @eweiss17 :sparkles: :thumbsup: :sparkles:
:cookie: 612 | @eweiss17 |http://www.freecodecamp.org/eweiss17
:star2: 2632 | @gulsvi |http://www.freecodecamp.org/gulsvi
['id', 'name'].forEach((attr) => $(field).attr(attr, (p, value) => value.replace(/\[[0-9]+\]/g, "[" + list_i + "]"));
https://codepen.io/CurtisjCamp/pen/gvdjOY?editors=0010
this is it so far its almost done but I want to change what gets displayed in the "progress bar"
Originally I was just going to show the minutes but I want it to shows seconds as well now. I feel like it should be just some simple math thrown in somewhere but I'm pretty frustrated.
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp);
return "Change Me!";
}
// Test your code by modifying these values
checkObj("gift");
function displayTimeLeft(seconds){
const minutes = Math.floor(seconds / 60);
const remainderSeconds = seconds % 60;
const displaySeconds = remainderSeconds >= 10 ? remainderSeconds : '0' + remainderSeconds;
const display = `${minutes}:${displaySeconds}`;
timerDisplay.textContent = display;
document.title = display;
}
myObj.hasOwnProperty(checkProp)
this returns true/false so you can use it in your if
curtisjcamp sends brownie points to @njm8 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @njm8 |http://www.freecodecamp.org/njm8
:star2: 9044 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
mananshah51 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9046 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
how can I update the "model" of the datatables so when changing the drop down on each row the data will get updated ? here is the testing page i am working on it testing page
I mean i want know when i am in table without adding selected inside the table html when click on option let's say it is cancel it will added selected to it so when i am filter to cancel value i will say only cancel , can anybody help me in this and here is the link
https://codepen.io/HusseinZaki/pen/QQzVNG @all
selected
expect(received).toBe(expected)
Expected value to be (using ===):
[["QUARTER", 50]]
Received:
[["QUARTER", 50]]
Difference:
Compared values have no visual difference.
@moT01 that what i am trying to do
so maybe, in that onchange event - there should be a way to change what is selected in the dropdown - it sounds like you filter by whatever option has
selected
describe('checkCashRegister', function() {
describe('#return a correct change record array', function() {
it('should return one array', function() {
assert.equal(
checkCashRegister(19.5, 20.0, [
['PENNY', 1.01],
['NICKEL', 2.05],
['DIME', 3.1],
['QUARTER', 4.25],
['ONE', 90.0],
['FIVE', 55.0],
['TEN', 20.0],
['TWENTY', 60.0],
['ONE HUNDRED', 100.0]
]),
[['QUARTER' , 50]]
);
});
});
});
===
I am not sure what makes the test fails when there is no visual difference
#navbar li {
display: inline-block;
padding-right: 100px;
margin: 25px;
float: right;
color: white;
}
#navbar li:hover {
color: orange
}
[['QUARTER' , 50]]
with an other array (that looks the same?)
navbar li
will do. I think it is because it didn't have specific target
[['QUARTER', 50]]
is the return value.
'1' == 1
returns true, or null == undefined
is true
heathercoraje sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 402 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
===
assert
instead of the jest built-in expect
?expect
toBe
is supposed to be deep comparision?
expect(received).toBe(expected)
Expected value to be (using ===):
[["QUARTER", 0.5]]
Received:
[["QUARTER", 0.5]]
Difference:
Compared values have no visual difference.
As far as I recall @bradtaniguchi jest implemented expect from expect.js
(another testing lib) that gives meaningful messages from testing.
for example
assert(4 >=0) && expect(4).toBeGreaterThanOrEqual(4)
will perform the same test, but assert
often reply with a simple expected true to be false
while expect
should be more informative on the tree error..
or so it used to be, i'm not on point with recent versions
toEqual
?
heathercoraje sends brownie points to @marmiz and @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:star2: 1179 | @marmiz |http://www.freecodecamp.org/marmiz
toBe
means literally is that element
. If your function returns a new element will fail (as it should)
const x = obj => Object.assign({}, obj)
test('is the same obj', () => {
const result = x({a: 1});
expect(result).toBe({a: 1}) // should fail
expect(result).toEqual({a: 1}) // should pass
})
toBe uses Object.is to test exact equality. If you want to check the value of an object, use toEqual instead:
I just realized I was using mocha
that's where the assert came from
do {
printf("How much change is owed: ");
change = get_float();
}
while(change < 0.00);
@bradtaniguchi I just tried the test I written above, this is the error message:
Compared values have no visual difference. Looks like you wanted to test for object/array equality with strict
toBe
matcher. You probably need to usetoEqual
instead.
More informative than the assert
" compared values have no visual difference"
(this should be a lesson for you @Heathercoraje as well! you could have solved it in a second)
to
2 more chars and solved it. My last 3hours..
@RandyGoldsmith you have defined change
outside the do while
as well otherwise this
change = get_float();
would throw an error (change type is not defined, at least here)
do while
, and that's because is defined somewhere else
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float change;
int totalCents;
do {
printf("How much change is owed: ");
change = get_float();
}
while(change < 0.00);
//convert $1: 100 cents
//multiplying the users input change amount by 100 to get the total amount of cents
printf("Answer is %f'", change)
//floating point imprecsion
//round
}
@RandyGoldsmith
i didnt save my first printf into a variable
of course you did:
change = get_float();
is reading whatever value the user input and assign it to change
randygoldsmith sends brownie points to @rdollent :sparkles: :thumbsup: :sparkles:
:cookie: 334 | @rdollent |http://www.freecodecamp.org/rdollent
fget
or another one i don't remember off the top of my head( I remember there were a few ways)
#include <cs50.h>
Hello guys !
Can someone help me out?
I have this navigation. When i scroll down the property 'black" should be added. When i scroll back up the black should be removed. When i scroll down the navigation should also follow, but i cant find the mistake, heres the link:
mustimuu sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 471 | @marianissimus |http://www.freecodecamp.org/marianissimus
position: fixed;
and width:100%
to the nav, then add margin: auto;
to the menu div
mustimuu sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 335 | @x140hu4 |http://www.freecodecamp.org/x140hu4
AngularJS x
means the old angular, and Angular x
means the new angular.
what would you recommend?
If i learn bootstrap and joomla and Sass?
I see
So if my goal is to be working at a company i should just start building pages and repeat
mustimuu sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
mustimuu sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @x140hu4 |http://www.freecodecamp.org/x140hu4
hello everoyone ..unable to get the weather data......here is the code.....function showPosition(position) {
var lati=position.coords.latitude;
var logi=position.coords.longitude;
x.innerHTML = "Latitude: " + lati + "<br>Longitude: " +logi;
var resultElement = $('#resultDiv');
var weather="https://api.openweathermap.org/data/2.5/weather?lat="+lati+"&lon="+logi+"&appid=7658e29ee6204da60dcec48c4cd297a5"
$.ajax({
url:'weather',
method:'get',
dataType:"json",
success:function(data){
resultElement.html('weather:'+data.weather[0].main+'<br/>'+'Description:'+data.weather[0].description);
}
});
}
crossOrigin = *
puneethnviraat sends brownie points to @aka-dev :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @aka-dev |http://www.freecodecamp.org/aka-dev
var weatherLink = api + "lon=" + lon + "&lat=" + lat;
zalmez sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 487 | @ezioda004 |http://www.freecodecamp.org/ezioda004
em
units (you'll need to use small numbers like 0.35em)
col
classes scale up, so just col-xs-2
would do the same as col-xs-2 col-md-2 col-xl-2
I think.
fez994 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4710 | @masd925 |http://www.freecodecamp.org/masd925
Can you pls explain me this line of code??
$("#display").html(eval(total));
what does the eval(total) does here??
spetsnaz-dev sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @x140hu4 |http://www.freecodecamp.org/x140hu4
html {
background: url(01860_sanfrancisco_2560x1600.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
waves-effect waves-light btn blue lighten-2 hoverable
?
html
rule in the CSS file, the button works?
ldocherty1 sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 927 | @h1tag |http://www.freecodecamp.org/h1tag
target='_blank'
, yes
darrenfj sends brownie points to @codernewby :sparkles: :thumbsup: :sparkles:
:cookie: 60 | @codernewby |http://www.freecodecamp.org/codernewby
kwfe sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @njm8 |http://www.freecodecamp.org/njm8
absolute
The element is removed from the normal document flow; no space is created for the element in the page layout. Instead, it is positioned relative to its closest positioned ancestor if any; otherwise, it is placed relative to the initial containing block. Its final position is determined by the values of top, right, bottom, and left. This value creates a new stacking context when the value of z-index is not auto. Absolutely positioned boxes can have margins, and they do not collapse with any other margins.
njm8 sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 928 | @h1tag |http://www.freecodecamp.org/h1tag
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2409 | @darrenfj |http://www.freecodecamp.org/darrenfj
yb1997 sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 929 | @h1tag |http://www.freecodecamp.org/h1tag