Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
js-e006
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Fernando David Lopez
js-e006
Commits
c7a3451c
Commit
c7a3451c
authored
Nov 08, 2018
by
roshka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JavaScript de Objetos
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
0 deletions
+125
-0
js006/js-006.html
+125
-0
No files found.
js006/js-006.html
0 → 100644
View file @
c7a3451c
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
JS-003
</title>
</head>
<body>
<!--Ejercicio 1-->
<script>
var
factura
=
{
id_factura
:
0
,
fecha
:
""
,
cliente
,
monto
:
0
,
tipo_factura
:
false
,
facturaEstado
:
function
(){
if
(
tipo_factura
=
false
)
{
return
this
.
tipo_factura
=
"Contado"
;
}
else
{
return
this
.
estado
=
"Credito"
;
}
},
cobrado
:
false
,
cobroEstado
:
function
(){
return
this
.
cobro
=
false
;
},
estado
:
false
,
estadoActual
:
function
(){
if
(
estado
=
false
)
{
return
this
.
estado
=
"Inactivo"
;
}
else
{
return
this
.
estado
=
"Activo"
;
}
}
};
var
detalle_factura
=
{
id_detalle
:
0
,
id_factura
:
0
,
cod_producto
:
0
,
cantidad
:
0
,
precio
:
0
,
total_linea
:
0
}
var
cliente
=
{
id_cliente
:
0
,
nombre
:
"------"
,
ruc
:
"999999"
,
email
:
"......"
,
direccion
:
"/////"
,
estado
:
factura
.
estado
}
/*Ejercicio 2*/
console
.
log
(
"Ejercicio 2"
);
var
vector
=
new
Array
();
var
FacturaIDV
,
tipoFacturaV
,
clienteV
,
diaV
,
mesV
,
estadoV
,
montoV
,
banderaV
;
for
(
i
=
0
;
i
<
100
;
i
++
)
{
FacturaIDV
=
parseInt
(
Math
.
random
()
*
1000000
);
diaV
=
parseInt
(
Math
.
random
()
*
30
);
mesV
=
parseInt
(
Math
.
random
()
*
12
);
if
(
i
%
2
==
0
)
{
tipoFacturaV
=
false
;
banderaV
=
false
;
estadoV
=
false
;
}
else
{
tipoFacturaV
=
true
;
banderaV
=
true
;
estadoV
=
true
;
}
vector
[
i
]
=
{
id_factura
:
FacturaIDV
,
fecha
:
+
diaV
+
"-"
+
mesV
,
cliente
:{
id_cliente
:
parseInt
(
Math
.
random
()
*
999
),
nombre
:
"------"
,
ruc
:
"999999"
,
email
:
"......"
,
direccion
:
"/////"
,
estado
:
estadoV
},
monto
:
montoV
,
tipo_factura
:
tipoFacturaV
,
cobrado
:
banderaV
,
estado
:
estadoV
}
}
/*Ejercicio 3*/
console
.
log
(
"Ejercicio 3"
);
for
(
i
=
0
;
i
<
100
;
i
++
)
{
if
(
vector
[
i
].
cobrado
==
true
)
{
console
.
log
(
vector
[
i
]);
}
}
/*Ejercicio 4*/
console
.
log
(
"Ejercicio 4"
);
var
contador
=
0
;
for
(
i
=
0
;
i
<
100
;
i
++
)
{
if
(
vector
[
i
].
cobrado
==
true
)
{
contador
+=
vector
[
i
].
monto
;
}
}
console
.
log
(
contador
);
/*Ejercicio 5*/
console
.
log
(
"Ejercicio 5"
);
var
bscFecha
=
"8/11"
;
for
(
i
=
0
;
i
<
100
;
i
++
)
{
if
(
vector
[
i
].
fecha
==
bscFecha
)
{
console
.
log
(
vector
[
i
]);
}
}
/*Ejercicio 6*/
console
.
log
(
"Ejercicion 6"
);
var
bscFactura
=
prompt
(
"Factura segun Contado o Credito [1,2]"
);
for
(
i
=
0
;
i
<
100
;
i
++
){
if
(
bscFactura
==
"1"
&&
vector
[
i
].
tipo_factura
==
"Contado"
)
{
console
.
log
(
vector
[
i
]);
}
if
(
bscFactura
==
"2"
&&
vector
[
i
].
tipo_factura
==
"Credito"
)
{
console
.
log
(
vector
[
i
]);
}
}
/*Ejercicio 7*/
console
.
log
(
"Ejercicio 7"
);
var
bscCodigoCliente
=
prompt
(
"Ingrese codigo de Cliente [1-999]"
);
for
(
i
=
0
;
i
<
100
;
i
++
)
{
if
(
vector
[
i
].
cliente
.
id_cliente
==
parseInt
(
bscCodigoCliente
))
{
console
.
log
(
vector
[
i
]);
}
}
</script>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment