Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // const k = 10;
- // switch (true) {
- // case k > 1 && k < 2:
- // console.log(k);
- // break;
- // case k == 10:
- // console.log("k==10");
- // break;
- // }
- // function Hello() {
- // this.a = 10;
- // }
- // // ?. ??
- // console.log(a.filter((v) => v % 2 === 0).sort((a, b) => b - a)[1]);
- // // a.reduce((acc,curr)=>{
- // // if(curr%2==0 ) return acc
- // // },0)
- // function SL(a) {
- // let SL = -Infinity,
- // L = -Infinity;
- // a= a.filter((v) => v % 2 === 0)
- // for (let val of a) {
- // if (val > SL && val < L) SL = val;
- // else if (val > L) {
- // SL = L;
- // L = val;
- // }
- // }
- // return SL
- // }
- // const a = [-2,-4,-8];
- // console.log(SL(a));
- // function* hello(){
- // yield 1;
- // yield 2;
- // }
- // const h1= hello()
- // console.log(h1.next().value)
- // // const
- // function hello(a,b){
- // return hello2(c){
- // }
- // }
- // hello(1,2)(3)
- // h1.addEventListener('click',()=>,true )
- // db.createCollection('')
- //
- class Node {
- constructor(val) {
- this.val = val;
- this.next = null;
- }
- }
- class LinkedList {
- constructor() {
- this.head = null;
- this.tail = null;
- }
- prepend(val) {
- const node = new Node(val);
- if (this.head) {
- node.next = this.head;
- } else {
- this.tail = node;
- }
- this.head = node;
- }
- //10,20,30
- revRecursive(curr = this.head, res = []) {
- if (!curr) return res.reverse();
- res.push(curr.val); //10 //10,20,30
- return this.revRecursive(curr.next, res);
- }
- }
- const list = new LinkedList();
- list.prepend(10);
- list.prepend(20);
- list.prepend(30);
- //30,20,10
- console.log(list.head)
- console.log(list.revRecursive());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement