//Q1 Consider the following code: function foo() { var a = 1; const b = 2; let c = 3; if (b < 10) { var a = 10; const b = 11; let c = 12; console.log(a, b, c); } console.log(a, b, c); console.log(d, e); var d = 4; const e = 5; } foo(); //What will be printed on the console? //Q2 const promise1 = new Promise((resolve, reject) => { console.log(1); resolve('success') }); promise1.then(() => { console.log(3); }); console.log(4); //What will be printed on the console? //Q3 Create a for loop that iterates up to 100 while outputting "fizz" at multiples of 3, "buzz" at multiples of 5 and "fizzbuzz" at multiples of 3 and 5. //Q4 Given two strings, return true if they are anagrams of one another var firstWord = "Listen"; var secondWord = "Silent"; isAnagram(firstWord, secondWord); // true function isAnagram(first, second) { // Your code goes here } // Q5 This is a piece of Angular code. Create a function that takes a string and returns a string in which each character is repeated once.Please also fill in the html part so the result will be render in the div.Eg: User type in "1234" in the textbox. The div will render "11223344" //HTML code <div class = "repeated string"> <input class= "form-control" [(ngModel)] = "formInput" (change) = "repeatedString()"> /* You code goes here. Please make sure the result display within the div 'result' */ <div class = "result"></div> </div> //TS code formInput: string; // You need to update the repeatedStringResult here. repeatedStringResult: string; public repeatedString(){ // Your code goes here }
Check out your Company Bowl for anonymous work chats.