lab 6 done
This commit is contained in:
19
labs/lab6/lab6.js
Normal file
19
labs/lab6/lab6.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function areNumbersEqual(num1,num2,percision){
|
||||
return Math.abs(num1 - num2) < percision;
|
||||
}
|
||||
|
||||
func=(...args) => {
|
||||
const percision=0.1E-2;
|
||||
args.sort();
|
||||
let out = "";
|
||||
let lastElem = null;
|
||||
for (let i = 0; i < args.length-1; i++){
|
||||
if (areNumbersEqual(args[i],args[i+1],percision) && (!areNumbersEqual(args[i],lastElem,percision) || lastElem === null)){
|
||||
lastElem = args[i];
|
||||
out += lastElem+" ";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
console.log(func(-0.0009111,0,-0.0009111,-0.009111,-0,1.1,1.101,2.0001,2))
|
||||
17
lectures/temp.js
Normal file
17
lectures/temp.js
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
function updateDict(dict, update) {
|
||||
let key, value = update.entries()[0];
|
||||
dict[key] = value + (key in dict) ? dict[key] : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
aboba={"asd":123}
|
||||
upd={"asd":123}
|
||||
upd1={"asd":123}
|
||||
|
||||
updateDict(aboba,upd1)
|
||||
console.log(aboba)
|
||||
updateDict(aboba,upd1)
|
||||
console.log(aboba)
|
||||
Reference in New Issue
Block a user