Solving a simple Javacript question using for loop and array

I am trying to solve this question using Javascript for loop and array but got stuck halfway. Need some guidance. So far what I came up with is this: const array1 = [‘S’,’A’,’I’,’N’,’S’]; var text=""; for(let y = 0; y < array1.length; y++){ text += array1[y]; console.log(text); } The output are: S SA SAI SAIN… Read More Solving a simple Javacript question using for loop and array

What is difference between these two pieces of code when we do operator overloading?

Code 1: class CVector { public: int x, y; CVector() {}; CVector(int a, int b) :x(a), y(b) {} }; CVector operator- (const CVector& lhs, const CVector& rhs) { CVector temp; temp.x = lhs.x – rhs.x; temp.y = lhs.y – rhs.y; return temp; } int main() { CVector foo(2, 3); CVector bar(3, 2); CVector result; result… Read More What is difference between these two pieces of code when we do operator overloading?