diff --git a/labs/lab6/lab6.js b/labs/lab6/lab6.js new file mode 100644 index 0000000..6694304 --- /dev/null +++ b/labs/lab6/lab6.js @@ -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)) diff --git a/lectures/temp.js b/lectures/temp.js new file mode 100644 index 0000000..5e93c8a --- /dev/null +++ b/lectures/temp.js @@ -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)