- 博客(10)
- 资源 (1)
- 收藏
- 关注
原创 移动端( H5 小程序)CSS 要点总结 ——持续更新
经常遇到坑…在W3C上学习了一段时间了,但是实际遇到的时候,细节多多。一一记录下来,温故而知新。1. CSS 截断字符串;{ /*指定字符串的宽度*/ width:300px; overflow: hidden; /* 当字符串超过规定长度,显示省略符*/ text-overflow:ellipsis; white-spac...
2018-08-15 16:30:20
468
原创 [JavaScript] 小练习 阶乘
使用递归来返回阶乘值;0的阶乘等于1;function factorialize(num) { return num>0? num * factorialize(num-1):1;}// test case;factorialize(5);
2018-08-06 16:54:42
255
原创 [JavaScript] 小练习 Cash Register 找零钱
原题:Design a cash register drawer function checkCashRegister()that accepts purchase price as the first argument (price), payment as the second argument (cash), and cash-in-drawer (cid) as the thir...
2018-08-05 16:42:30
1008
翻译 [JavaScript] 小练习 US telephone number validator
function telephoneCheck(str) { // regular expression making up var reg = /^(1\s?)?(\(\d{3}\)|\d{3})[\-\s]?\d{3}[\-\s]?\d{4}$/; return reg.test(str);} //test casetelephoneCheck("555-555-5555"...
2018-08-05 09:53:21
259
翻译 [JavaScript] 小练习 Arguments Optional
function addTogether() { var args = Array.from(arguments); return args.some(arg => typeof(arg)!=='number')? undefined: args.length > 1 ? args.reduce((acc,n) => acc+=n, 0):...
2018-08-04 16:16:45
230
翻译 [JavaScript] 小练习 check if every object in list has the property
function(collection, pre){ return collection.every( (obj) => obj.hasOwnProperty(pre) && Boolean(obj[pre]))}//test case check if every object in the array has the property or...
2018-08-04 15:41:36
129
翻译 [JavaScript] 小练习 binary string transformation
function binaryAgent(str) { return String.fromCharCode(...str.split(" ").map((char) => parseInt(char,2)));}binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010...
2018-08-04 15:18:31
343
翻译 [JavaScript] 小练习 Steamroller
function steamrollArray(arr) { let flattenedArray = []; //recursion function function flattenArray(arg){ //initialize an empty array if(!Array.isArray(arg)) flattenedArray.push(a...
2018-08-04 12:03:44
155
原创 [JavaScript] 小练习 给出小于 arg 的所有质数的总和
function sumPrimes(num) { // arg smaller than 2 is unnecessary.. if(num<2) return 'invalid input'; // create a full array.. var arr=[]; for (let iterator=2; iterator<=num; iterator++)...
2018-08-03 10:40:28
209
原创 [JavaScript] 小练习 生成斐波那契数列
function sumFibs(num) { if(num<2) return 1; //initialize an array with the first two numbers; var arr = [1,1]; //generate the array with While loop while((arr[arr.length-1] + arr[arr.len...
2018-08-02 17:37:01
339
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人