changyang 最近的时间轴更新
changyang

changyang

V2EX 第 392647 号会员,加入于 2019-03-16 11:14:14 +08:00
今日活跃度排名 1003
changyang 最近回复了
```javascript
//看了一下问题,不知道我理解对了没,以下是我的思路:
//把 invoice 和 transaction 都当作一个交易表里面的记录,只是 type 不一样,就可以解决
const transactions = [
{ id: 1, type: 'invoice', name: 'JNL001',amount:100,balance:100 },
{ id: 2, type: 'invoice', name: 'JNL002',amount:-100,balance:0 },
{ id: 3, type: 'invoice', name: 'JNL003',amount:100,balance:100 },
{ id: 4, type: 'invoice', name: 'JNL004',amount:-100,balance:0 },
{ id: 5, type: 'invoice', name: 'JNL005',amount:130,balance:130 },
{ id: 6, type: 'transaction', name: 'INV001',amount:-100,balance:30 },
{ id: 7, type: 'invoice', name: 'JNL006',amount:100,balance:130 },
{ id: 8, type: 'invoice', name: 'JNL007',amount:-100,balance:30 },
{ id: 9, type: 'transaction', name: 'INV002',amount:-100,balance:0 }
];

function findRecordsBetween(name) {
const index = transactions.findIndex(transaction => {
if (transaction.name === name){
if(transaction.type === 'transaction'){
return true;
}else {
throw new Error('必须输入一个 transaction 的 name');
}
}
});
if (index === -1) {
return []; // 如果未找到与该名称匹配的记录,返回空数组
}
const transactionIndex = transactions.slice(0, index ).findLastIndex(transaction => transaction.type === 'transaction');
if (transactionIndex === -1) {
return transactions.slice(0, index); // 如果未找到最近一次 transaction ,返回到开始所有记录
}

return transactions.slice(transactionIndex + 1, index);
}

// 用例:

console.log(findRecordsBetween('INV001'));


```
2022-12-15 14:04:45 +08:00
回复了 yfixx 创建的主题 DevOps 怎么做好运维
@ReZer0 桌面运维确实很苦逼,多年前做过一段时间 IT 客服(内部的)。客户的问题千奇百怪,打印机卡纸,电脑连不上网,vpn 登不上这都属于正常的。有些财务 excel 函数不会用,有些采购 foxmail 不会用,他 /她都要找你处理。烦是真的烦,不过比程序员好一点的是更有机会遇见爱情(前提是你服务心态好的情况下)。
2022-11-02 15:22:12 +08:00
回复了 reayyu 创建的主题 硬件 决赛圈了,两套 4090 整机选哪个比较划算?
自己配一套啊,4090 先不买,买个健身卡用,到时候再卖了换 4090 不就完美解决了嘛
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   6342 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms · UTC 01:56 · PVG 09:56 · LAX 18:56 · JFK 21:56
Developed with CodeLauncher
♥ Do have faith in what you're doing.