Category : conditional-statements

I want to come out of a nested if loop if a particular condition is met. Below is the snippet:- cy.get(A).then(()=>{ do{ cy.get(B).each(()=>{ switch(C){ case "1": if(some condition){ this.method1() return false //THIS IS NOT BREAKING THE OUTERMOST THEN LOOP !!!!! } method2() break case "2": if(some condition){ this.method3() return false } method4() break } //switch ..

Read more

import useStyles from ‘./styles’; const Likes = () => { if (post.likes.length > 0) { return post.likes.find((like) => like === (user?.result?.googleId || user?.result?._id)) ? ( <><ThumbUpAltIcon fontSize="small" />&nbsp;{post.likes.length > 2 ? `you and ${post.likes.length – 1} others` : `${post.likes.length} like${post.likes.length > 1 ? ‘s’ : ”}`}</> ) : ( <><ThumbUpAltOutlined fontSize="small" />&nbsp;{post.likes.length} {post.likes.length === 1 ..

Read more