function strLength(s) {
var length = 0;
while (s[length] !== undefined)
length++;
return length;
}
console.log(strLength("Hello")); // 5
console.log(strLength("")); // 0
-------------------------------------------------------------------
Floyd’s Triangle: Javascript
OUTPUR:1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Var tempStr = "",prevNumber=1,i,depth=10; for(i=0;i<depth;i++){ tempStr = "";j=0; while(j<= i){ tempStr = tempStr + " " + prevNumber; j++; prevNumber++; } console.log(tempStr); }
________________________________________________________
what is difference between - $(<div/>) vs $('div')
$('<div/>').addClass('sample-piece'); create a new div element and add class sample-piece to it. The new created div is not in the dom tree at that time, you may need to append it to some other element.$('div').addClass('sample-piece'); add class sample-piece to the all the div elements in the dom tree. summarize:
$('<div/>') creates a new div element.$('div') selects all the div elements.-----------------------------------------------------------------
http methods in html
Two HTTP Request Methods: GET and POST
Two commonly used methods for a request-response between a client and server are: GET and POST.- GET - Requests data from a specified resource
- POST - Submits data to be processed to a specified resource
The data-* attributes is used to store custom data private to the page or application.
The data-* attributes gives us the ability to embed custom data attributes on all HTML elements.
The stored (custom) data can then be used in the page's JavaScript to create a more engaging user experience (without any Ajax calls or server-side database queries)
----------------------
n HTML5, the tabindex attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).
In HTML 4.01, the tabindex attribute can be used with: <a>, <area>, <button>, <input>, <object>, <select>, and <textarea>.
-----------
The novalidate attribute is new in HTML5.
---------------------
what is the purpose of base tag in html
<base href="https://www.w3schools.com/images/" target="_blank">
The <base> tag specifies the base URL/target for all relative URLs in a document. There can be at maximum one <base> element in a document, and it must be inside the <head> element.
----
The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.
The
---------------
n HTML5, the tabindex attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).
In HTML 4.01, the tabindex attribute can be used with: <a>, <area>, <button>, <input>, <object>, <select>, and <textarea>.
-----------
The novalidate attribute is new in HTML5.
<form novalidate>
------------------
---------------------
what is the purpose of base tag in html
<base href="https://www.w3schools.com/images/" target="_blank">
The <base> tag specifies the base URL/target for all relative URLs in a document. There can be at maximum one <base> element in a document, and it must be inside the <head> element.
----
The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.
- Content - The content of the box, where text and images appear
- Padding - Clears an area around the content. The padding is transparent
- Border - A border that goes around the padding and content
- Margin - Clears an area outside the border. The margin is transparent
The
box-sizing property defines how the width and height of an element are
calculated: should they include padding and borders, or not.
box-sizing: content-box|border-box|initial|inherit;
* {
box-sizing: border-box;}
----------------
<style>
i {
border: solid black;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
}
.up {
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
}
</style>
</head>
<body>
<h2>CSS Arrows</h2>
<p>Up arrow: <i class="up"></i></p>
</body>
---------------
@font-face {
font-family: 'MyWebFont';
src: url('myfont.woff2') format('woff2'),
url('myfont.woff') format('woff');
}